[Java] Update auto-generated bindings
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
159         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
161                 (*env)->ExceptionDescribe(env);
162                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
163         }
164         switch (ord) {
165                 case 0: return LDKAccessError_UnknownChain;
166                 case 1: return LDKAccessError_UnknownTx;
167         }
168         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
169         abort(); // Unreachable, but will let the compiler know we don't return here
170 }
171 static jclass AccessError_class = NULL;
172 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
173 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
174 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
175         AccessError_class = (*env)->NewGlobalRef(env, clz);
176         CHECK(AccessError_class != NULL);
177         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
179         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
180         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
181 }
182 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
183         switch (val) {
184                 case LDKAccessError_UnknownChain:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
186                 case LDKAccessError_UnknownTx:
187                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
188                 default: abort();
189         }
190 }
191
192 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
193         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
194         if (UNLIKELY((*env)->ExceptionCheck(env))) {
195                 (*env)->ExceptionDescribe(env);
196                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
197         }
198         switch (ord) {
199                 case 0: return LDKCOption_NoneZ_Some;
200                 case 1: return LDKCOption_NoneZ_None;
201         }
202         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
203         abort(); // Unreachable, but will let the compiler know we don't return here
204 }
205 static jclass COption_NoneZ_class = NULL;
206 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
207 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
208 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
209         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
210         CHECK(COption_NoneZ_class != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
213         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
214         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
215 }
216 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
217         switch (val) {
218                 case LDKCOption_NoneZ_Some:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
220                 case LDKCOption_NoneZ_None:
221                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
222                 default: abort();
223         }
224 }
225
226 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
227         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
229                 (*env)->ExceptionDescribe(env);
230                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
231         }
232         switch (ord) {
233                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
234                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
235         }
236         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
237         abort(); // Unreachable, but will let the compiler know we don't return here
238 }
239 static jclass ChannelMonitorUpdateErr_class = NULL;
240 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
241 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
242 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
243         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
244         CHECK(ChannelMonitorUpdateErr_class != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
247         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
248         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
249 }
250 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
251         switch (val) {
252                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
254                 case LDKChannelMonitorUpdateErr_PermanentFailure:
255                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
256                 default: abort();
257         }
258 }
259
260 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
261         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
263                 (*env)->ExceptionDescribe(env);
264                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
265         }
266         switch (ord) {
267                 case 0: return LDKConfirmationTarget_Background;
268                 case 1: return LDKConfirmationTarget_Normal;
269                 case 2: return LDKConfirmationTarget_HighPriority;
270         }
271         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
272         abort(); // Unreachable, but will let the compiler know we don't return here
273 }
274 static jclass ConfirmationTarget_class = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
276 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
277 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
279         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(ConfirmationTarget_class != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
285         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
286         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
287 }
288 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
289         switch (val) {
290                 case LDKConfirmationTarget_Background:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
292                 case LDKConfirmationTarget_Normal:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
294                 case LDKConfirmationTarget_HighPriority:
295                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
296                 default: abort();
297         }
298 }
299
300 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
301         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
303                 (*env)->ExceptionDescribe(env);
304                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
305         }
306         switch (ord) {
307                 case 0: return LDKCreationError_DescriptionTooLong;
308                 case 1: return LDKCreationError_RouteTooLong;
309                 case 2: return LDKCreationError_TimestampOutOfBounds;
310                 case 3: return LDKCreationError_InvalidAmount;
311                 case 4: return LDKCreationError_MissingRouteHints;
312         }
313         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
314         abort(); // Unreachable, but will let the compiler know we don't return here
315 }
316 static jclass CreationError_class = NULL;
317 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
318 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
319 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
320 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
321 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
322 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
323         CreationError_class = (*env)->NewGlobalRef(env, clz);
324         CHECK(CreationError_class != NULL);
325         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
327         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
329         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
335 }
336 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
337         switch (val) {
338                 case LDKCreationError_DescriptionTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
340                 case LDKCreationError_RouteTooLong:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
342                 case LDKCreationError_TimestampOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 case LDKCreationError_MissingRouteHints:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
348                 default: abort();
349         }
350 }
351
352 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
353         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
355                 (*env)->ExceptionDescribe(env);
356                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
357         }
358         switch (ord) {
359                 case 0: return LDKCurrency_Bitcoin;
360                 case 1: return LDKCurrency_BitcoinTestnet;
361                 case 2: return LDKCurrency_Regtest;
362                 case 3: return LDKCurrency_Simnet;
363                 case 4: return LDKCurrency_Signet;
364         }
365         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
366         abort(); // Unreachable, but will let the compiler know we don't return here
367 }
368 static jclass Currency_class = NULL;
369 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
370 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
371 static jfieldID Currency_LDKCurrency_Regtest = NULL;
372 static jfieldID Currency_LDKCurrency_Simnet = NULL;
373 static jfieldID Currency_LDKCurrency_Signet = NULL;
374 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
375         Currency_class = (*env)->NewGlobalRef(env, clz);
376         CHECK(Currency_class != NULL);
377         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
379         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
381         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Regtest != NULL);
383         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Simnet != NULL);
385         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
386         CHECK(Currency_LDKCurrency_Signet != NULL);
387 }
388 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
389         switch (val) {
390                 case LDKCurrency_Bitcoin:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
392                 case LDKCurrency_BitcoinTestnet:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
394                 case LDKCurrency_Regtest:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
396                 case LDKCurrency_Simnet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
398                 case LDKCurrency_Signet:
399                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
400                 default: abort();
401         }
402 }
403
404 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKIOError_NotFound;
412                 case 1: return LDKIOError_PermissionDenied;
413                 case 2: return LDKIOError_ConnectionRefused;
414                 case 3: return LDKIOError_ConnectionReset;
415                 case 4: return LDKIOError_ConnectionAborted;
416                 case 5: return LDKIOError_NotConnected;
417                 case 6: return LDKIOError_AddrInUse;
418                 case 7: return LDKIOError_AddrNotAvailable;
419                 case 8: return LDKIOError_BrokenPipe;
420                 case 9: return LDKIOError_AlreadyExists;
421                 case 10: return LDKIOError_WouldBlock;
422                 case 11: return LDKIOError_InvalidInput;
423                 case 12: return LDKIOError_InvalidData;
424                 case 13: return LDKIOError_TimedOut;
425                 case 14: return LDKIOError_WriteZero;
426                 case 15: return LDKIOError_Interrupted;
427                 case 16: return LDKIOError_Other;
428                 case 17: return LDKIOError_UnexpectedEof;
429         }
430         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
431         abort(); // Unreachable, but will let the compiler know we don't return here
432 }
433 static jclass IOError_class = NULL;
434 static jfieldID IOError_LDKIOError_NotFound = NULL;
435 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
437 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
438 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
439 static jfieldID IOError_LDKIOError_NotConnected = NULL;
440 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
441 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
442 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
443 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
444 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
445 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
446 static jfieldID IOError_LDKIOError_InvalidData = NULL;
447 static jfieldID IOError_LDKIOError_TimedOut = NULL;
448 static jfieldID IOError_LDKIOError_WriteZero = NULL;
449 static jfieldID IOError_LDKIOError_Interrupted = NULL;
450 static jfieldID IOError_LDKIOError_Other = NULL;
451 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
452 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
453         IOError_class = (*env)->NewGlobalRef(env, clz);
454         CHECK(IOError_class != NULL);
455         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_NotFound != NULL);
457         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
459         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
461         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
463         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
465         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_NotConnected != NULL);
467         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrInUse != NULL);
469         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
471         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
473         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
475         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_WouldBlock != NULL);
477         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidInput != NULL);
479         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_InvalidData != NULL);
481         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_TimedOut != NULL);
483         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_WriteZero != NULL);
485         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Interrupted != NULL);
487         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_Other != NULL);
489         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
490         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
491 }
492 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
493         switch (val) {
494                 case LDKIOError_NotFound:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
496                 case LDKIOError_PermissionDenied:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
498                 case LDKIOError_ConnectionRefused:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
500                 case LDKIOError_ConnectionReset:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
502                 case LDKIOError_ConnectionAborted:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
504                 case LDKIOError_NotConnected:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
506                 case LDKIOError_AddrInUse:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
508                 case LDKIOError_AddrNotAvailable:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
510                 case LDKIOError_BrokenPipe:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
512                 case LDKIOError_AlreadyExists:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
514                 case LDKIOError_WouldBlock:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
516                 case LDKIOError_InvalidInput:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
518                 case LDKIOError_InvalidData:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
520                 case LDKIOError_TimedOut:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
522                 case LDKIOError_WriteZero:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
524                 case LDKIOError_Interrupted:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
526                 case LDKIOError_Other:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
528                 case LDKIOError_UnexpectedEof:
529                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
530                 default: abort();
531         }
532 }
533
534 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
535         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
537                 (*env)->ExceptionDescribe(env);
538                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
539         }
540         switch (ord) {
541                 case 0: return LDKLevel_Gossip;
542                 case 1: return LDKLevel_Trace;
543                 case 2: return LDKLevel_Debug;
544                 case 3: return LDKLevel_Info;
545                 case 4: return LDKLevel_Warn;
546                 case 5: return LDKLevel_Error;
547         }
548         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
549         abort(); // Unreachable, but will let the compiler know we don't return here
550 }
551 static jclass Level_class = NULL;
552 static jfieldID Level_LDKLevel_Gossip = NULL;
553 static jfieldID Level_LDKLevel_Trace = NULL;
554 static jfieldID Level_LDKLevel_Debug = NULL;
555 static jfieldID Level_LDKLevel_Info = NULL;
556 static jfieldID Level_LDKLevel_Warn = NULL;
557 static jfieldID Level_LDKLevel_Error = NULL;
558 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
559         Level_class = (*env)->NewGlobalRef(env, clz);
560         CHECK(Level_class != NULL);
561         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Gossip != NULL);
563         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Trace != NULL);
565         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Debug != NULL);
567         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Info != NULL);
569         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Warn != NULL);
571         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
572         CHECK(Level_LDKLevel_Error != NULL);
573 }
574 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
575         switch (val) {
576                 case LDKLevel_Gossip:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
578                 case LDKLevel_Trace:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
580                 case LDKLevel_Debug:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
582                 case LDKLevel_Info:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
584                 case LDKLevel_Warn:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
586                 case LDKLevel_Error:
587                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
588                 default: abort();
589         }
590 }
591
592 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
593         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
595                 (*env)->ExceptionDescribe(env);
596                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
597         }
598         switch (ord) {
599                 case 0: return LDKNetwork_Bitcoin;
600                 case 1: return LDKNetwork_Testnet;
601                 case 2: return LDKNetwork_Regtest;
602                 case 3: return LDKNetwork_Signet;
603         }
604         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
605         abort(); // Unreachable, but will let the compiler know we don't return here
606 }
607 static jclass Network_class = NULL;
608 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
609 static jfieldID Network_LDKNetwork_Testnet = NULL;
610 static jfieldID Network_LDKNetwork_Regtest = NULL;
611 static jfieldID Network_LDKNetwork_Signet = NULL;
612 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
613         Network_class = (*env)->NewGlobalRef(env, clz);
614         CHECK(Network_class != NULL);
615         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Bitcoin != NULL);
617         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Testnet != NULL);
619         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Regtest != NULL);
621         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
622         CHECK(Network_LDKNetwork_Signet != NULL);
623 }
624 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
625         switch (val) {
626                 case LDKNetwork_Bitcoin:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
628                 case LDKNetwork_Testnet:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
630                 case LDKNetwork_Regtest:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
632                 case LDKNetwork_Signet:
633                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
634                 default: abort();
635         }
636 }
637
638 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
639         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
641                 (*env)->ExceptionDescribe(env);
642                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKRecipient_Node;
646                 case 1: return LDKRecipient_PhantomNode;
647         }
648         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
649         abort(); // Unreachable, but will let the compiler know we don't return here
650 }
651 static jclass Recipient_class = NULL;
652 static jfieldID Recipient_LDKRecipient_Node = NULL;
653 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
654 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
655         Recipient_class = (*env)->NewGlobalRef(env, clz);
656         CHECK(Recipient_class != NULL);
657         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_Node != NULL);
659         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
660         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
661 }
662 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
663         switch (val) {
664                 case LDKRecipient_Node:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
666                 case LDKRecipient_PhantomNode:
667                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
668                 default: abort();
669         }
670 }
671
672 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
673         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
675                 (*env)->ExceptionDescribe(env);
676                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
677         }
678         switch (ord) {
679                 case 0: return LDKSecp256k1Error_IncorrectSignature;
680                 case 1: return LDKSecp256k1Error_InvalidMessage;
681                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
682                 case 3: return LDKSecp256k1Error_InvalidSignature;
683                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
684                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
685                 case 6: return LDKSecp256k1Error_InvalidTweak;
686                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688         }
689         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
690         abort(); // Unreachable, but will let the compiler know we don't return here
691 }
692 static jclass Secp256k1Error_class = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
702 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
703         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
704         CHECK(Secp256k1Error_class != NULL);
705         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
706         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
707         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
719         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
721         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
723 }
724 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
725         switch (val) {
726                 case LDKSecp256k1Error_IncorrectSignature:
727                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
728                 case LDKSecp256k1Error_InvalidMessage:
729                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
730                 case LDKSecp256k1Error_InvalidPublicKey:
731                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
732                 case LDKSecp256k1Error_InvalidSignature:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
734                 case LDKSecp256k1Error_InvalidSecretKey:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
736                 case LDKSecp256k1Error_InvalidRecoveryId:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
738                 case LDKSecp256k1Error_InvalidTweak:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
740                 case LDKSecp256k1Error_TweakCheckFailed:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
742                 case LDKSecp256k1Error_NotEnoughMemory:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
744                 default: abort();
745         }
746 }
747
748 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
749         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
751                 (*env)->ExceptionDescribe(env);
752                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
753         }
754         switch (ord) {
755                 case 0: return LDKSemanticError_NoPaymentHash;
756                 case 1: return LDKSemanticError_MultiplePaymentHashes;
757                 case 2: return LDKSemanticError_NoDescription;
758                 case 3: return LDKSemanticError_MultipleDescriptions;
759                 case 4: return LDKSemanticError_NoPaymentSecret;
760                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
761                 case 6: return LDKSemanticError_InvalidFeatures;
762                 case 7: return LDKSemanticError_InvalidRecoveryId;
763                 case 8: return LDKSemanticError_InvalidSignature;
764                 case 9: return LDKSemanticError_ImpreciseAmount;
765         }
766         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
767         abort(); // Unreachable, but will let the compiler know we don't return here
768 }
769 static jclass SemanticError_class = NULL;
770 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
771 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
772 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
773 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
774 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
775 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
776 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
777 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
778 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
779 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
780 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
781         SemanticError_class = (*env)->NewGlobalRef(env, clz);
782         CHECK(SemanticError_class != NULL);
783         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
784         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
785         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
786         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
787         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
788         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
789         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
790         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
791         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
792         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
793         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
795         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
797         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
799         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
801         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
803 }
804 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
805         switch (val) {
806                 case LDKSemanticError_NoPaymentHash:
807                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
808                 case LDKSemanticError_MultiplePaymentHashes:
809                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
810                 case LDKSemanticError_NoDescription:
811                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
812                 case LDKSemanticError_MultipleDescriptions:
813                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
814                 case LDKSemanticError_NoPaymentSecret:
815                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
816                 case LDKSemanticError_MultiplePaymentSecrets:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
818                 case LDKSemanticError_InvalidFeatures:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
820                 case LDKSemanticError_InvalidRecoveryId:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
822                 case LDKSemanticError_InvalidSignature:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
824                 case LDKSemanticError_ImpreciseAmount:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
826                 default: abort();
827         }
828 }
829
830 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
831         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
833                 (*env)->ExceptionDescribe(env);
834                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
835         }
836         switch (ord) {
837                 case 0: return LDKSiPrefix_Milli;
838                 case 1: return LDKSiPrefix_Micro;
839                 case 2: return LDKSiPrefix_Nano;
840                 case 3: return LDKSiPrefix_Pico;
841         }
842         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
843         abort(); // Unreachable, but will let the compiler know we don't return here
844 }
845 static jclass SiPrefix_class = NULL;
846 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
847 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
848 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
849 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
850 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
851         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
852         CHECK(SiPrefix_class != NULL);
853         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
854         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
855         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
856         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
857         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
858         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
859         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
860         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
861 }
862 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
863         switch (val) {
864                 case LDKSiPrefix_Milli:
865                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
866                 case LDKSiPrefix_Micro:
867                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
868                 case LDKSiPrefix_Nano:
869                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
870                 case LDKSiPrefix_Pico:
871                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
872                 default: abort();
873         }
874 }
875
876 static jclass LDKBech32Error_MissingSeparator_class = NULL;
877 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
878 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
879 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
880 static jclass LDKBech32Error_InvalidLength_class = NULL;
881 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
882 static jclass LDKBech32Error_InvalidChar_class = NULL;
883 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
884 static jclass LDKBech32Error_InvalidData_class = NULL;
885 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
886 static jclass LDKBech32Error_InvalidPadding_class = NULL;
887 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
888 static jclass LDKBech32Error_MixedCase_class = NULL;
889 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
891         LDKBech32Error_MissingSeparator_class =
892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
893         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
894         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
895         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
896         LDKBech32Error_InvalidChecksum_class =
897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
898         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
899         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
900         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
901         LDKBech32Error_InvalidLength_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
903         CHECK(LDKBech32Error_InvalidLength_class != NULL);
904         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
905         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
906         LDKBech32Error_InvalidChar_class =
907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
908         CHECK(LDKBech32Error_InvalidChar_class != NULL);
909         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
910         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
911         LDKBech32Error_InvalidData_class =
912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
913         CHECK(LDKBech32Error_InvalidData_class != NULL);
914         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
915         CHECK(LDKBech32Error_InvalidData_meth != NULL);
916         LDKBech32Error_InvalidPadding_class =
917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
918         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
919         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
920         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
921         LDKBech32Error_MixedCase_class =
922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
923         CHECK(LDKBech32Error_MixedCase_class != NULL);
924         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
925         CHECK(LDKBech32Error_MixedCase_meth != NULL);
926 }
927 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
928         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
929         switch(obj->tag) {
930                 case LDKBech32Error_MissingSeparator: {
931                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
932                 }
933                 case LDKBech32Error_InvalidChecksum: {
934                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
935                 }
936                 case LDKBech32Error_InvalidLength: {
937                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
938                 }
939                 case LDKBech32Error_InvalidChar: {
940                         int32_t invalid_char_conv = obj->invalid_char;
941                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
942                 }
943                 case LDKBech32Error_InvalidData: {
944                         int8_t invalid_data_conv = obj->invalid_data;
945                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
946                 }
947                 case LDKBech32Error_InvalidPadding: {
948                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
949                 }
950                 case LDKBech32Error_MixedCase: {
951                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
952                 }
953                 default: abort();
954         }
955 }
956 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
957         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
958         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
959         return ret;
960 }
961 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) {
962         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
963         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
964         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
965         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
966         CVec_u8Z_free(ret_var);
967         return ret_arr;
968 }
969
970 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) {
971         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
972         int64_t ret_conv = TxOut_get_value(thing_conv);
973         return ret_conv;
974 }
975
976 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
977 CHECK(owner->result_ok);
978         return *owner->contents.result;
979 }
980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
981         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
982         CResult_NoneNoneZ_get_ok(owner_conv);
983 }
984
985 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
986 CHECK(!owner->result_ok);
987         return *owner->contents.err;
988 }
989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
990         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
991         CResult_NoneNoneZ_get_err(owner_conv);
992 }
993
994 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
995 CHECK(owner->result_ok);
996         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
997 }
998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
999         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1000         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1001         int64_t ret_ref = 0;
1002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1005         ret_ref = (uintptr_t)ret_var.inner;
1006         if (ret_var.is_owned) {
1007                 ret_ref |= 1;
1008         }
1009         return ret_ref;
1010 }
1011
1012 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1013 CHECK(!owner->result_ok);
1014         return DecodeError_clone(&*owner->contents.err);
1015 }
1016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1017         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1018         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1019         int64_t ret_ref = 0;
1020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1023         ret_ref = (uintptr_t)ret_var.inner;
1024         if (ret_var.is_owned) {
1025                 ret_ref |= 1;
1026         }
1027         return ret_ref;
1028 }
1029
1030 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1031 CHECK(owner->result_ok);
1032         return *owner->contents.result;
1033 }
1034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1035         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1036         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1038         return ret_arr;
1039 }
1040
1041 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1042 CHECK(!owner->result_ok);
1043         return *owner->contents.err;
1044 }
1045 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1046         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1047         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1048         return ret_conv;
1049 }
1050
1051 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1052 CHECK(owner->result_ok);
1053         return *owner->contents.result;
1054 }
1055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1056         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1057         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1058         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1059         return ret_arr;
1060 }
1061
1062 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1063 CHECK(!owner->result_ok);
1064         return *owner->contents.err;
1065 }
1066 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1067         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1068         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1069         return ret_conv;
1070 }
1071
1072 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1073 CHECK(owner->result_ok);
1074         return TxCreationKeys_clone(&*owner->contents.result);
1075 }
1076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1077         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1078         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1079         int64_t ret_ref = 0;
1080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1083         ret_ref = (uintptr_t)ret_var.inner;
1084         if (ret_var.is_owned) {
1085                 ret_ref |= 1;
1086         }
1087         return ret_ref;
1088 }
1089
1090 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1091 CHECK(!owner->result_ok);
1092         return DecodeError_clone(&*owner->contents.err);
1093 }
1094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1095         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1096         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1097         int64_t ret_ref = 0;
1098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1101         ret_ref = (uintptr_t)ret_var.inner;
1102         if (ret_var.is_owned) {
1103                 ret_ref |= 1;
1104         }
1105         return ret_ref;
1106 }
1107
1108 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1109 CHECK(owner->result_ok);
1110         return ChannelPublicKeys_clone(&*owner->contents.result);
1111 }
1112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1113         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1114         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1115         int64_t ret_ref = 0;
1116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1119         ret_ref = (uintptr_t)ret_var.inner;
1120         if (ret_var.is_owned) {
1121                 ret_ref |= 1;
1122         }
1123         return ret_ref;
1124 }
1125
1126 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1127 CHECK(!owner->result_ok);
1128         return DecodeError_clone(&*owner->contents.err);
1129 }
1130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1131         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1132         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1133         int64_t ret_ref = 0;
1134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1137         ret_ref = (uintptr_t)ret_var.inner;
1138         if (ret_var.is_owned) {
1139                 ret_ref |= 1;
1140         }
1141         return ret_ref;
1142 }
1143
1144 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1145 CHECK(owner->result_ok);
1146         return TxCreationKeys_clone(&*owner->contents.result);
1147 }
1148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1149         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1150         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1151         int64_t ret_ref = 0;
1152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1155         ret_ref = (uintptr_t)ret_var.inner;
1156         if (ret_var.is_owned) {
1157                 ret_ref |= 1;
1158         }
1159         return ret_ref;
1160 }
1161
1162 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1163 CHECK(!owner->result_ok);
1164         return *owner->contents.err;
1165 }
1166 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1167         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1168         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1169         return ret_conv;
1170 }
1171
1172 static jclass LDKCOption_u32Z_Some_class = NULL;
1173 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1174 static jclass LDKCOption_u32Z_None_class = NULL;
1175 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1177         LDKCOption_u32Z_Some_class =
1178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1179         CHECK(LDKCOption_u32Z_Some_class != NULL);
1180         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1181         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1182         LDKCOption_u32Z_None_class =
1183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1184         CHECK(LDKCOption_u32Z_None_class != NULL);
1185         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1186         CHECK(LDKCOption_u32Z_None_meth != NULL);
1187 }
1188 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1189         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1190         switch(obj->tag) {
1191                 case LDKCOption_u32Z_Some: {
1192                         int32_t some_conv = obj->some;
1193                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1194                 }
1195                 case LDKCOption_u32Z_None: {
1196                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1197                 }
1198                 default: abort();
1199         }
1200 }
1201 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1202 CHECK(owner->result_ok);
1203         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1204 }
1205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1206         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1207         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1208         int64_t ret_ref = 0;
1209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1212         ret_ref = (uintptr_t)ret_var.inner;
1213         if (ret_var.is_owned) {
1214                 ret_ref |= 1;
1215         }
1216         return ret_ref;
1217 }
1218
1219 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1220 CHECK(!owner->result_ok);
1221         return DecodeError_clone(&*owner->contents.err);
1222 }
1223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1224         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1225         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1226         int64_t ret_ref = 0;
1227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1230         ret_ref = (uintptr_t)ret_var.inner;
1231         if (ret_var.is_owned) {
1232                 ret_ref |= 1;
1233         }
1234         return ret_ref;
1235 }
1236
1237 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1238 CHECK(owner->result_ok);
1239         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1240 }
1241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1242         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1243         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1244         int64_t ret_ref = 0;
1245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1248         ret_ref = (uintptr_t)ret_var.inner;
1249         if (ret_var.is_owned) {
1250                 ret_ref |= 1;
1251         }
1252         return ret_ref;
1253 }
1254
1255 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1256 CHECK(!owner->result_ok);
1257         return DecodeError_clone(&*owner->contents.err);
1258 }
1259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1260         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1261         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1262         int64_t ret_ref = 0;
1263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1266         ret_ref = (uintptr_t)ret_var.inner;
1267         if (ret_var.is_owned) {
1268                 ret_ref |= 1;
1269         }
1270         return ret_ref;
1271 }
1272
1273 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1274 CHECK(owner->result_ok);
1275         return ChannelTransactionParameters_clone(&*owner->contents.result);
1276 }
1277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1278         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1279         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1280         int64_t ret_ref = 0;
1281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1284         ret_ref = (uintptr_t)ret_var.inner;
1285         if (ret_var.is_owned) {
1286                 ret_ref |= 1;
1287         }
1288         return ret_ref;
1289 }
1290
1291 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1292 CHECK(!owner->result_ok);
1293         return DecodeError_clone(&*owner->contents.err);
1294 }
1295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1296         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1297         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1298         int64_t ret_ref = 0;
1299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1302         ret_ref = (uintptr_t)ret_var.inner;
1303         if (ret_var.is_owned) {
1304                 ret_ref |= 1;
1305         }
1306         return ret_ref;
1307 }
1308
1309 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1310 CHECK(owner->result_ok);
1311         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1312 }
1313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1314         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1315         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1316         int64_t ret_ref = 0;
1317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1320         ret_ref = (uintptr_t)ret_var.inner;
1321         if (ret_var.is_owned) {
1322                 ret_ref |= 1;
1323         }
1324         return ret_ref;
1325 }
1326
1327 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1328 CHECK(!owner->result_ok);
1329         return DecodeError_clone(&*owner->contents.err);
1330 }
1331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1332         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1333         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1334         int64_t ret_ref = 0;
1335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1338         ret_ref = (uintptr_t)ret_var.inner;
1339         if (ret_var.is_owned) {
1340                 ret_ref |= 1;
1341         }
1342         return ret_ref;
1343 }
1344
1345 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1346 CHECK(owner->result_ok);
1347         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1348 }
1349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1350         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1351         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1352         int64_t ret_ref = 0;
1353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1356         ret_ref = (uintptr_t)ret_var.inner;
1357         if (ret_var.is_owned) {
1358                 ret_ref |= 1;
1359         }
1360         return ret_ref;
1361 }
1362
1363 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1364 CHECK(!owner->result_ok);
1365         return DecodeError_clone(&*owner->contents.err);
1366 }
1367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1368         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1369         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1370         int64_t ret_ref = 0;
1371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1374         ret_ref = (uintptr_t)ret_var.inner;
1375         if (ret_var.is_owned) {
1376                 ret_ref |= 1;
1377         }
1378         return ret_ref;
1379 }
1380
1381 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1382 CHECK(owner->result_ok);
1383         return &*owner->contents.result;
1384 }
1385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1386         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1387         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1388         int64_t ret_ref = 0;
1389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1392         ret_ref = (uintptr_t)ret_var.inner & ~1;
1393         return ret_ref;
1394 }
1395
1396 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1397 CHECK(!owner->result_ok);
1398         return *owner->contents.err;
1399 }
1400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1401         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1402         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1403 }
1404
1405 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1406 CHECK(owner->result_ok);
1407         return CommitmentTransaction_clone(&*owner->contents.result);
1408 }
1409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1410         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1411         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1412         int64_t ret_ref = 0;
1413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1416         ret_ref = (uintptr_t)ret_var.inner;
1417         if (ret_var.is_owned) {
1418                 ret_ref |= 1;
1419         }
1420         return ret_ref;
1421 }
1422
1423 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1424 CHECK(!owner->result_ok);
1425         return DecodeError_clone(&*owner->contents.err);
1426 }
1427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1428         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1429         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1430         int64_t ret_ref = 0;
1431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1434         ret_ref = (uintptr_t)ret_var.inner;
1435         if (ret_var.is_owned) {
1436                 ret_ref |= 1;
1437         }
1438         return ret_ref;
1439 }
1440
1441 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1442 CHECK(owner->result_ok);
1443         return &*owner->contents.result;
1444 }
1445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1446         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1447         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1448         int64_t ret_ref = 0;
1449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1452         ret_ref = (uintptr_t)ret_var.inner & ~1;
1453         return ret_ref;
1454 }
1455
1456 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1457 CHECK(!owner->result_ok);
1458         return *owner->contents.err;
1459 }
1460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1461         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1462         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1463 }
1464
1465 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1466 CHECK(owner->result_ok);
1467         return *owner->contents.result;
1468 }
1469 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1470         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1471         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1472         jobjectArray ret_arr = NULL;
1473         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1474         ;
1475         for (size_t i = 0; i < ret_var.datalen; i++) {
1476                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1477                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1478                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1479         }
1480         
1481         return ret_arr;
1482 }
1483
1484 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1485 CHECK(!owner->result_ok);
1486         return *owner->contents.err;
1487 }
1488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1489         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1490         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1491 }
1492
1493 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1494 CHECK(owner->result_ok);
1495         return ShutdownScript_clone(&*owner->contents.result);
1496 }
1497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1498         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1499         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1500         int64_t ret_ref = 0;
1501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1504         ret_ref = (uintptr_t)ret_var.inner;
1505         if (ret_var.is_owned) {
1506                 ret_ref |= 1;
1507         }
1508         return ret_ref;
1509 }
1510
1511 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1512 CHECK(!owner->result_ok);
1513         return DecodeError_clone(&*owner->contents.err);
1514 }
1515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1516         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1517         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1518         int64_t ret_ref = 0;
1519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1522         ret_ref = (uintptr_t)ret_var.inner;
1523         if (ret_var.is_owned) {
1524                 ret_ref |= 1;
1525         }
1526         return ret_ref;
1527 }
1528
1529 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1530 CHECK(owner->result_ok);
1531         return ShutdownScript_clone(&*owner->contents.result);
1532 }
1533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1534         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1535         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1536         int64_t ret_ref = 0;
1537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1540         ret_ref = (uintptr_t)ret_var.inner;
1541         if (ret_var.is_owned) {
1542                 ret_ref |= 1;
1543         }
1544         return ret_ref;
1545 }
1546
1547 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1548 CHECK(!owner->result_ok);
1549         return InvalidShutdownScript_clone(&*owner->contents.err);
1550 }
1551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1552         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1553         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1554         int64_t ret_ref = 0;
1555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1558         ret_ref = (uintptr_t)ret_var.inner;
1559         if (ret_var.is_owned) {
1560                 ret_ref |= 1;
1561         }
1562         return ret_ref;
1563 }
1564
1565 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1566 CHECK(owner->result_ok);
1567         return *owner->contents.result;
1568 }
1569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1570         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1571         CResult_NoneErrorZ_get_ok(owner_conv);
1572 }
1573
1574 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1575 CHECK(!owner->result_ok);
1576         return *owner->contents.err;
1577 }
1578 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1579         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1580         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1581         return ret_conv;
1582 }
1583
1584 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1585 CHECK(owner->result_ok);
1586         return RouteHop_clone(&*owner->contents.result);
1587 }
1588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1589         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1590         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1591         int64_t ret_ref = 0;
1592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1595         ret_ref = (uintptr_t)ret_var.inner;
1596         if (ret_var.is_owned) {
1597                 ret_ref |= 1;
1598         }
1599         return ret_ref;
1600 }
1601
1602 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1603 CHECK(!owner->result_ok);
1604         return DecodeError_clone(&*owner->contents.err);
1605 }
1606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1607         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1608         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1609         int64_t ret_ref = 0;
1610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1613         ret_ref = (uintptr_t)ret_var.inner;
1614         if (ret_var.is_owned) {
1615                 ret_ref |= 1;
1616         }
1617         return ret_ref;
1618 }
1619
1620 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1621         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1622         for (size_t i = 0; i < ret.datalen; i++) {
1623                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1624         }
1625         return ret;
1626 }
1627 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1628         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1629         for (size_t i = 0; i < ret.datalen; i++) {
1630                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1631         }
1632         return ret;
1633 }
1634 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1635 CHECK(owner->result_ok);
1636         return Route_clone(&*owner->contents.result);
1637 }
1638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1639         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1640         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1641         int64_t ret_ref = 0;
1642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1645         ret_ref = (uintptr_t)ret_var.inner;
1646         if (ret_var.is_owned) {
1647                 ret_ref |= 1;
1648         }
1649         return ret_ref;
1650 }
1651
1652 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1653 CHECK(!owner->result_ok);
1654         return DecodeError_clone(&*owner->contents.err);
1655 }
1656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1657         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1658         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1659         int64_t ret_ref = 0;
1660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1663         ret_ref = (uintptr_t)ret_var.inner;
1664         if (ret_var.is_owned) {
1665                 ret_ref |= 1;
1666         }
1667         return ret_ref;
1668 }
1669
1670 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1671 CHECK(owner->result_ok);
1672         return RouteParameters_clone(&*owner->contents.result);
1673 }
1674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1675         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1676         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1677         int64_t ret_ref = 0;
1678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1681         ret_ref = (uintptr_t)ret_var.inner;
1682         if (ret_var.is_owned) {
1683                 ret_ref |= 1;
1684         }
1685         return ret_ref;
1686 }
1687
1688 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1689 CHECK(!owner->result_ok);
1690         return DecodeError_clone(&*owner->contents.err);
1691 }
1692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1693         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1694         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1695         int64_t ret_ref = 0;
1696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1699         ret_ref = (uintptr_t)ret_var.inner;
1700         if (ret_var.is_owned) {
1701                 ret_ref |= 1;
1702         }
1703         return ret_ref;
1704 }
1705
1706 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1707         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1708         for (size_t i = 0; i < ret.datalen; i++) {
1709                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1710         }
1711         return ret;
1712 }
1713 static jclass LDKCOption_u64Z_Some_class = NULL;
1714 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1715 static jclass LDKCOption_u64Z_None_class = NULL;
1716 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1718         LDKCOption_u64Z_Some_class =
1719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1720         CHECK(LDKCOption_u64Z_Some_class != NULL);
1721         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1722         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1723         LDKCOption_u64Z_None_class =
1724                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1725         CHECK(LDKCOption_u64Z_None_class != NULL);
1726         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1727         CHECK(LDKCOption_u64Z_None_meth != NULL);
1728 }
1729 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1730         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1731         switch(obj->tag) {
1732                 case LDKCOption_u64Z_Some: {
1733                         int64_t some_conv = obj->some;
1734                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1735                 }
1736                 case LDKCOption_u64Z_None: {
1737                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1738                 }
1739                 default: abort();
1740         }
1741 }
1742 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1743 CHECK(owner->result_ok);
1744         return PaymentParameters_clone(&*owner->contents.result);
1745 }
1746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1747         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1748         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1749         int64_t ret_ref = 0;
1750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1753         ret_ref = (uintptr_t)ret_var.inner;
1754         if (ret_var.is_owned) {
1755                 ret_ref |= 1;
1756         }
1757         return ret_ref;
1758 }
1759
1760 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1761 CHECK(!owner->result_ok);
1762         return DecodeError_clone(&*owner->contents.err);
1763 }
1764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1765         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1766         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1767         int64_t ret_ref = 0;
1768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1771         ret_ref = (uintptr_t)ret_var.inner;
1772         if (ret_var.is_owned) {
1773                 ret_ref |= 1;
1774         }
1775         return ret_ref;
1776 }
1777
1778 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1779         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1780         for (size_t i = 0; i < ret.datalen; i++) {
1781                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1782         }
1783         return ret;
1784 }
1785 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1786 CHECK(owner->result_ok);
1787         return RouteHint_clone(&*owner->contents.result);
1788 }
1789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1790         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1791         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1792         int64_t ret_ref = 0;
1793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1796         ret_ref = (uintptr_t)ret_var.inner;
1797         if (ret_var.is_owned) {
1798                 ret_ref |= 1;
1799         }
1800         return ret_ref;
1801 }
1802
1803 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1804 CHECK(!owner->result_ok);
1805         return DecodeError_clone(&*owner->contents.err);
1806 }
1807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1808         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1809         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1810         int64_t ret_ref = 0;
1811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1814         ret_ref = (uintptr_t)ret_var.inner;
1815         if (ret_var.is_owned) {
1816                 ret_ref |= 1;
1817         }
1818         return ret_ref;
1819 }
1820
1821 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1822 CHECK(owner->result_ok);
1823         return RouteHintHop_clone(&*owner->contents.result);
1824 }
1825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1826         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1827         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1828         int64_t ret_ref = 0;
1829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1832         ret_ref = (uintptr_t)ret_var.inner;
1833         if (ret_var.is_owned) {
1834                 ret_ref |= 1;
1835         }
1836         return ret_ref;
1837 }
1838
1839 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1840 CHECK(!owner->result_ok);
1841         return DecodeError_clone(&*owner->contents.err);
1842 }
1843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1844         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1845         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1846         int64_t ret_ref = 0;
1847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1850         ret_ref = (uintptr_t)ret_var.inner;
1851         if (ret_var.is_owned) {
1852                 ret_ref |= 1;
1853         }
1854         return ret_ref;
1855 }
1856
1857 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1858         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1859         for (size_t i = 0; i < ret.datalen; i++) {
1860                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1861         }
1862         return ret;
1863 }
1864 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1865 CHECK(owner->result_ok);
1866         return Route_clone(&*owner->contents.result);
1867 }
1868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1869         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1870         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1871         int64_t ret_ref = 0;
1872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1875         ret_ref = (uintptr_t)ret_var.inner;
1876         if (ret_var.is_owned) {
1877                 ret_ref |= 1;
1878         }
1879         return ret_ref;
1880 }
1881
1882 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1883 CHECK(!owner->result_ok);
1884         return LightningError_clone(&*owner->contents.err);
1885 }
1886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1887         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1888         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1889         int64_t ret_ref = 0;
1890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1893         ret_ref = (uintptr_t)ret_var.inner;
1894         if (ret_var.is_owned) {
1895                 ret_ref |= 1;
1896         }
1897         return ret_ref;
1898 }
1899
1900 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1901 CHECK(owner->result_ok);
1902         return TxOut_clone(&*owner->contents.result);
1903 }
1904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1905         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1906         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1907         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1908         return (int64_t)ret_ref;
1909 }
1910
1911 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1912 CHECK(!owner->result_ok);
1913         return AccessError_clone(&*owner->contents.err);
1914 }
1915 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1916         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1917         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
1918         return ret_conv;
1919 }
1920
1921 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1922         return owner->a;
1923 }
1924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
1925         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1926         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1927         return ret_conv;
1928 }
1929
1930 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1931         return owner->b;
1932 }
1933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
1934         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1935         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1936         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1937         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1938         return ret_arr;
1939 }
1940
1941 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1942         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1943         for (size_t i = 0; i < ret.datalen; i++) {
1944                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1945         }
1946         return ret;
1947 }
1948 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1949         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1950         for (size_t i = 0; i < ret.datalen; i++) {
1951                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1952         }
1953         return ret;
1954 }
1955 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1956 CHECK(owner->result_ok);
1957         return *owner->contents.result;
1958 }
1959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1960         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1961         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1962 }
1963
1964 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1965 CHECK(!owner->result_ok);
1966         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1967 }
1968 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1969         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1970         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1971         return ret_conv;
1972 }
1973
1974 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1975 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1976 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1977 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1978 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1979 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1980 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1981 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1983         LDKMonitorEvent_HTLCEvent_class =
1984                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1985         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1986         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1987         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1988         LDKMonitorEvent_CommitmentTxConfirmed_class =
1989                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1990         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1991         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1992         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1993         LDKMonitorEvent_UpdateCompleted_class =
1994                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1995         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1996         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1997         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1998         LDKMonitorEvent_UpdateFailed_class =
1999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
2000         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
2001         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
2002         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
2003 }
2004 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2005         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2006         switch(obj->tag) {
2007                 case LDKMonitorEvent_HTLCEvent: {
2008                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2009                         int64_t htlc_event_ref = 0;
2010                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2011                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2012                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2013                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2014                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
2015                 }
2016                 case LDKMonitorEvent_CommitmentTxConfirmed: {
2017                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2018                         int64_t commitment_tx_confirmed_ref = 0;
2019                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2020                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2021                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2022                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2023                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
2024                 }
2025                 case LDKMonitorEvent_UpdateCompleted: {
2026                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2027                         int64_t funding_txo_ref = 0;
2028                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2029                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2030                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2031                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2032                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2033                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
2034                 }
2035                 case LDKMonitorEvent_UpdateFailed: {
2036                         LDKOutPoint update_failed_var = obj->update_failed;
2037                         int64_t update_failed_ref = 0;
2038                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2039                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2040                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2041                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2042                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
2043                 }
2044                 default: abort();
2045         }
2046 }
2047 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2048         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2049         for (size_t i = 0; i < ret.datalen; i++) {
2050                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2051         }
2052         return ret;
2053 }
2054 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
2055 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
2056 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
2057 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
2058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
2059         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
2060                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
2061         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
2062         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
2063         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
2064         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
2065                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
2066         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
2067         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
2068         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
2069 }
2070 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2071         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2072         switch(obj->tag) {
2073                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2074                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2075                         *some_conv = obj->some;
2076                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2077                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
2078                 }
2079                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2080                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
2081                 }
2082                 default: abort();
2083         }
2084 }
2085 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2086 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2087 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2088 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2089 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2090 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2091 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2092 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2093 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2094 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2095 static jclass LDKClosureReason_ProcessingError_class = NULL;
2096 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2097 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2098 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2099 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2100 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2102         LDKClosureReason_CounterpartyForceClosed_class =
2103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2104         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2105         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2106         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2107         LDKClosureReason_HolderForceClosed_class =
2108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2109         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2110         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2111         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2112         LDKClosureReason_CooperativeClosure_class =
2113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2114         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2115         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2116         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2117         LDKClosureReason_CommitmentTxConfirmed_class =
2118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2119         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2120         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2121         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2122         LDKClosureReason_FundingTimedOut_class =
2123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2124         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2125         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2126         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2127         LDKClosureReason_ProcessingError_class =
2128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2129         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2130         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2131         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2132         LDKClosureReason_DisconnectedPeer_class =
2133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2134         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2135         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2136         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2137         LDKClosureReason_OutdatedChannelManager_class =
2138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2139         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2140         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2141         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2142 }
2143 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2144         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2145         switch(obj->tag) {
2146                 case LDKClosureReason_CounterpartyForceClosed: {
2147                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2148                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2149                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2150                 }
2151                 case LDKClosureReason_HolderForceClosed: {
2152                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2153                 }
2154                 case LDKClosureReason_CooperativeClosure: {
2155                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2156                 }
2157                 case LDKClosureReason_CommitmentTxConfirmed: {
2158                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2159                 }
2160                 case LDKClosureReason_FundingTimedOut: {
2161                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2162                 }
2163                 case LDKClosureReason_ProcessingError: {
2164                         LDKStr err_str = obj->processing_error.err;
2165                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2166                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2167                 }
2168                 case LDKClosureReason_DisconnectedPeer: {
2169                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2170                 }
2171                 case LDKClosureReason_OutdatedChannelManager: {
2172                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2173                 }
2174                 default: abort();
2175         }
2176 }
2177 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2178 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2179 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2180 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2182         LDKCOption_ClosureReasonZ_Some_class =
2183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2184         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2185         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2186         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2187         LDKCOption_ClosureReasonZ_None_class =
2188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2189         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2190         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2191         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2192 }
2193 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2194         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2195         switch(obj->tag) {
2196                 case LDKCOption_ClosureReasonZ_Some: {
2197                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2198                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2199                 }
2200                 case LDKCOption_ClosureReasonZ_None: {
2201                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2202                 }
2203                 default: abort();
2204         }
2205 }
2206 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2207 CHECK(owner->result_ok);
2208         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2209 }
2210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2211         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2212         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2213         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2214         int64_t ret_ref = (uintptr_t)ret_copy;
2215         return ret_ref;
2216 }
2217
2218 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2219 CHECK(!owner->result_ok);
2220         return DecodeError_clone(&*owner->contents.err);
2221 }
2222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2223         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2224         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2225         int64_t ret_ref = 0;
2226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2229         ret_ref = (uintptr_t)ret_var.inner;
2230         if (ret_var.is_owned) {
2231                 ret_ref |= 1;
2232         }
2233         return ret_ref;
2234 }
2235
2236 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2237 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2238 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
2239 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
2240 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2241 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2243         LDKNetworkUpdate_ChannelUpdateMessage_class =
2244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2245         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2246         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2247         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2248         LDKNetworkUpdate_ChannelClosed_class =
2249                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
2250         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
2251         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2252         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
2253         LDKNetworkUpdate_NodeFailure_class =
2254                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2255         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2256         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2257         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2258 }
2259 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2260         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2261         switch(obj->tag) {
2262                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2263                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2264                         int64_t msg_ref = 0;
2265                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2266                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2267                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2268                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2269                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2270                 }
2271                 case LDKNetworkUpdate_ChannelClosed: {
2272                         int64_t short_channel_id_conv = obj->channel_closed.short_channel_id;
2273                         jboolean is_permanent_conv = obj->channel_closed.is_permanent;
2274                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, short_channel_id_conv, is_permanent_conv);
2275                 }
2276                 case LDKNetworkUpdate_NodeFailure: {
2277                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2278                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2279                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2280                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2281                 }
2282                 default: abort();
2283         }
2284 }
2285 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2286 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2287 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2288 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2290         LDKCOption_NetworkUpdateZ_Some_class =
2291                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2292         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2293         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2294         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2295         LDKCOption_NetworkUpdateZ_None_class =
2296                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2297         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2298         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2299         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2300 }
2301 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2302         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2303         switch(obj->tag) {
2304                 case LDKCOption_NetworkUpdateZ_Some: {
2305                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2306                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2307                 }
2308                 case LDKCOption_NetworkUpdateZ_None: {
2309                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2310                 }
2311                 default: abort();
2312         }
2313 }
2314 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2315 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2316 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2317 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2318 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2319 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2321         LDKSpendableOutputDescriptor_StaticOutput_class =
2322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2323         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2324         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2325         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2326         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2328         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2329         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2330         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2331         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2333         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2334         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2335         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2336 }
2337 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2338         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2339         switch(obj->tag) {
2340                 case LDKSpendableOutputDescriptor_StaticOutput: {
2341                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2342                         int64_t outpoint_ref = 0;
2343                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2344                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2345                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2346                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2347                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2348                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2349                 }
2350                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2351                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2352                         int64_t delayed_payment_output_ref = 0;
2353                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2354                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2355                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2356                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2357                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2358                 }
2359                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2360                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2361                         int64_t static_payment_output_ref = 0;
2362                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2363                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2364                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2365                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2366                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2367                 }
2368                 default: abort();
2369         }
2370 }
2371 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2372         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2373         for (size_t i = 0; i < ret.datalen; i++) {
2374                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2375         }
2376         return ret;
2377 }
2378 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2379 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2380 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2381 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2383         LDKPaymentPurpose_InvoicePayment_class =
2384                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2385         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2386         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2387         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2388         LDKPaymentPurpose_SpontaneousPayment_class =
2389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2390         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2391         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2392         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2393 }
2394 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2395         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
2396         switch(obj->tag) {
2397                 case LDKPaymentPurpose_InvoicePayment: {
2398                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2399                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2400                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2401                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2402                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2403                 }
2404                 case LDKPaymentPurpose_SpontaneousPayment: {
2405                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2406                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2407                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2408                 }
2409                 default: abort();
2410         }
2411 }
2412 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2413 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2414 static jclass LDKEvent_PaymentReceived_class = NULL;
2415 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2416 static jclass LDKEvent_PaymentSent_class = NULL;
2417 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2418 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2419 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2420 static jclass LDKEvent_PaymentFailed_class = NULL;
2421 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2422 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2423 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2424 static jclass LDKEvent_SpendableOutputs_class = NULL;
2425 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2426 static jclass LDKEvent_PaymentForwarded_class = NULL;
2427 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2428 static jclass LDKEvent_ChannelClosed_class = NULL;
2429 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2430 static jclass LDKEvent_DiscardFunding_class = NULL;
2431 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2432 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2433 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2434 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2435 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2437         LDKEvent_FundingGenerationReady_class =
2438                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2439         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2440         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
2441         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2442         LDKEvent_PaymentReceived_class =
2443                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2444         CHECK(LDKEvent_PaymentReceived_class != NULL);
2445         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2446         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2447         LDKEvent_PaymentSent_class =
2448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2449         CHECK(LDKEvent_PaymentSent_class != NULL);
2450         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2451         CHECK(LDKEvent_PaymentSent_meth != NULL);
2452         LDKEvent_PaymentPathFailed_class =
2453                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2454         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2455         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2456         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2457         LDKEvent_PaymentFailed_class =
2458                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2459         CHECK(LDKEvent_PaymentFailed_class != NULL);
2460         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2461         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2462         LDKEvent_PendingHTLCsForwardable_class =
2463                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2464         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2465         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2466         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2467         LDKEvent_SpendableOutputs_class =
2468                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2469         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2470         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2471         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2472         LDKEvent_PaymentForwarded_class =
2473                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2474         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2475         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
2476         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2477         LDKEvent_ChannelClosed_class =
2478                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2479         CHECK(LDKEvent_ChannelClosed_class != NULL);
2480         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2481         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2482         LDKEvent_DiscardFunding_class =
2483                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2484         CHECK(LDKEvent_DiscardFunding_class != NULL);
2485         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2486         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2487         LDKEvent_PaymentPathSuccessful_class =
2488                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2489         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2490         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2491         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2492         LDKEvent_OpenChannelRequest_class =
2493                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2494         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2495         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2496         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2497 }
2498 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2499         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2500         switch(obj->tag) {
2501                 case LDKEvent_FundingGenerationReady: {
2502                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2503                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2504                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2505                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2506                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2507                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2508                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2509                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2510                 }
2511                 case LDKEvent_PaymentReceived: {
2512                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2513                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2514                         int64_t amt_conv = obj->payment_received.amt;
2515                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2516                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amt_conv, purpose_ref);
2517                 }
2518                 case LDKEvent_PaymentSent: {
2519                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2520                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2521                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2522                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2523                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2524                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2525                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2526                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2527                 }
2528                 case LDKEvent_PaymentPathFailed: {
2529                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2530                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2531                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2532                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2533                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2534                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2535                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2536                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2537                         int64_tArray path_arr = NULL;
2538                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2539                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2540                         for (size_t k = 0; k < path_var.datalen; k++) {
2541                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2542                                 int64_t path_conv_10_ref = 0;
2543                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2544                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2545                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2546                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2547                                 path_arr_ptr[k] = path_conv_10_ref;
2548                         }
2549                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2550                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2551                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2552                         int64_t retry_ref = 0;
2553                         if ((uintptr_t)retry_var.inner > 4096) {
2554                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2555                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2556                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2557                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2558                         }
2559                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, rejected_by_dest_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
2560                 }
2561                 case LDKEvent_PaymentFailed: {
2562                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2563                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2564                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2565                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2566                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2567                 }
2568                 case LDKEvent_PendingHTLCsForwardable: {
2569                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2570                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2571                 }
2572                 case LDKEvent_SpendableOutputs: {
2573                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2574                         int64_tArray outputs_arr = NULL;
2575                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2576                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2577                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2578                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2579                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2580                         }
2581                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2582                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2583                 }
2584                 case LDKEvent_PaymentForwarded: {
2585                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2586                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2587                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2588                 }
2589                 case LDKEvent_ChannelClosed: {
2590                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2591                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2592                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2593                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2594                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2595                 }
2596                 case LDKEvent_DiscardFunding: {
2597                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2598                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2599                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2600                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2601                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2602                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2603                 }
2604                 case LDKEvent_PaymentPathSuccessful: {
2605                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2606                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2607                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2608                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2609                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2610                         int64_tArray path_arr = NULL;
2611                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2612                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2613                         for (size_t k = 0; k < path_var.datalen; k++) {
2614                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2615                                 int64_t path_conv_10_ref = 0;
2616                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2617                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2618                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2619                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2620                                 path_arr_ptr[k] = path_conv_10_ref;
2621                         }
2622                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2623                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2624                 }
2625                 case LDKEvent_OpenChannelRequest: {
2626                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2627                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2628                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2629                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2630                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2631                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2632                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2633                         int64_t channel_type_ref = 0;
2634                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2635                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2636                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2637                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2638                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, funding_satoshis_conv, push_msat_conv, channel_type_ref);
2639                 }
2640                 default: abort();
2641         }
2642 }
2643 static jclass LDKCOption_EventZ_Some_class = NULL;
2644 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2645 static jclass LDKCOption_EventZ_None_class = NULL;
2646 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2648         LDKCOption_EventZ_Some_class =
2649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2650         CHECK(LDKCOption_EventZ_Some_class != NULL);
2651         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2652         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2653         LDKCOption_EventZ_None_class =
2654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2655         CHECK(LDKCOption_EventZ_None_class != NULL);
2656         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2657         CHECK(LDKCOption_EventZ_None_meth != NULL);
2658 }
2659 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2660         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2661         switch(obj->tag) {
2662                 case LDKCOption_EventZ_Some: {
2663                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2664                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2665                 }
2666                 case LDKCOption_EventZ_None: {
2667                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2668                 }
2669                 default: abort();
2670         }
2671 }
2672 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2673 CHECK(owner->result_ok);
2674         return COption_EventZ_clone(&*owner->contents.result);
2675 }
2676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2677         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2678         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2679         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2680         int64_t ret_ref = (uintptr_t)ret_copy;
2681         return ret_ref;
2682 }
2683
2684 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2685 CHECK(!owner->result_ok);
2686         return DecodeError_clone(&*owner->contents.err);
2687 }
2688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2689         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2690         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2691         int64_t ret_ref = 0;
2692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2695         ret_ref = (uintptr_t)ret_var.inner;
2696         if (ret_var.is_owned) {
2697                 ret_ref |= 1;
2698         }
2699         return ret_ref;
2700 }
2701
2702 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2703 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2704 static jclass LDKErrorAction_IgnoreError_class = NULL;
2705 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2706 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2707 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2708 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2709 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2710 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2711 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2712 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2713 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2715         LDKErrorAction_DisconnectPeer_class =
2716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2717         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2718         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2719         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2720         LDKErrorAction_IgnoreError_class =
2721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2722         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2723         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2724         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2725         LDKErrorAction_IgnoreAndLog_class =
2726                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2727         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2728         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2729         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2730         LDKErrorAction_IgnoreDuplicateGossip_class =
2731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2732         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2733         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2734         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2735         LDKErrorAction_SendErrorMessage_class =
2736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2737         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2738         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2739         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2740         LDKErrorAction_SendWarningMessage_class =
2741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2742         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2743         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2744         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2745 }
2746 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2747         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2748         switch(obj->tag) {
2749                 case LDKErrorAction_DisconnectPeer: {
2750                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2751                         int64_t msg_ref = 0;
2752                         if ((uintptr_t)msg_var.inner > 4096) {
2753                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2754                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2755                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2756                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2757                         }
2758                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2759                 }
2760                 case LDKErrorAction_IgnoreError: {
2761                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2762                 }
2763                 case LDKErrorAction_IgnoreAndLog: {
2764                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2765                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2766                 }
2767                 case LDKErrorAction_IgnoreDuplicateGossip: {
2768                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2769                 }
2770                 case LDKErrorAction_SendErrorMessage: {
2771                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2772                         int64_t msg_ref = 0;
2773                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2774                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2775                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2776                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2777                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2778                 }
2779                 case LDKErrorAction_SendWarningMessage: {
2780                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2781                         int64_t msg_ref = 0;
2782                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2783                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2784                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2785                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2786                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2787                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2788                 }
2789                 default: abort();
2790         }
2791 }
2792 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2793 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2794 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2795 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2796 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2797 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2798 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2799 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2800 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2801 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2802 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2803 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2804 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2805 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2806 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2807 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2808 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2809 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2810 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2811 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2812 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2813 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2814 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2815 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2816 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2817 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2818 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2819 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2820 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2821 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2822 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2823 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2824 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2825 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2826 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2827 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2828 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2829 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2830 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2831 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2833         LDKMessageSendEvent_SendAcceptChannel_class =
2834                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2835         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2836         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2837         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2838         LDKMessageSendEvent_SendOpenChannel_class =
2839                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2840         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2841         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2842         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2843         LDKMessageSendEvent_SendFundingCreated_class =
2844                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2845         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2846         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2847         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2848         LDKMessageSendEvent_SendFundingSigned_class =
2849                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2850         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2851         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2852         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2853         LDKMessageSendEvent_SendFundingLocked_class =
2854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2855         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2856         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2857         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2858         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2860         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2861         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2862         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2863         LDKMessageSendEvent_UpdateHTLCs_class =
2864                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2865         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2866         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2867         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2868         LDKMessageSendEvent_SendRevokeAndACK_class =
2869                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2870         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2871         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2872         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2873         LDKMessageSendEvent_SendClosingSigned_class =
2874                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2875         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2876         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2877         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2878         LDKMessageSendEvent_SendShutdown_class =
2879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2880         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2881         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2882         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2883         LDKMessageSendEvent_SendChannelReestablish_class =
2884                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2885         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2886         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2887         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2888         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2889                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2890         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2891         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2892         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2893         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2895         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2896         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2897         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2898         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2899                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2900         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2901         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2902         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2903         LDKMessageSendEvent_SendChannelUpdate_class =
2904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2905         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2906         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2907         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2908         LDKMessageSendEvent_HandleError_class =
2909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2910         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2911         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2912         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2913         LDKMessageSendEvent_SendChannelRangeQuery_class =
2914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2915         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2916         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2917         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2918         LDKMessageSendEvent_SendShortIdsQuery_class =
2919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2920         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2921         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2922         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2923         LDKMessageSendEvent_SendReplyChannelRange_class =
2924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2925         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2926         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2927         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2928         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2929                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2930         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2931         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2932         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2933 }
2934 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2935         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2936         switch(obj->tag) {
2937                 case LDKMessageSendEvent_SendAcceptChannel: {
2938                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2939                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2940                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2941                         int64_t msg_ref = 0;
2942                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2943                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2944                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2945                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2946                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2947                 }
2948                 case LDKMessageSendEvent_SendOpenChannel: {
2949                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2950                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2951                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2952                         int64_t msg_ref = 0;
2953                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2954                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2955                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2956                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2957                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2958                 }
2959                 case LDKMessageSendEvent_SendFundingCreated: {
2960                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2961                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2962                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2963                         int64_t msg_ref = 0;
2964                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2965                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2966                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2967                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2968                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2969                 }
2970                 case LDKMessageSendEvent_SendFundingSigned: {
2971                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2972                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2973                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2974                         int64_t msg_ref = 0;
2975                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2976                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2977                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2978                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2979                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2980                 }
2981                 case LDKMessageSendEvent_SendFundingLocked: {
2982                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2983                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2984                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2985                         int64_t msg_ref = 0;
2986                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2987                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2988                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2989                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2990                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2991                 }
2992                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2993                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2994                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2995                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2996                         int64_t msg_ref = 0;
2997                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2998                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2999                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3000                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3001                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3002                 }
3003                 case LDKMessageSendEvent_UpdateHTLCs: {
3004                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3005                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3006                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3007                         int64_t updates_ref = 0;
3008                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3009                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3010                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3011                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3012                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3013                 }
3014                 case LDKMessageSendEvent_SendRevokeAndACK: {
3015                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3016                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3017                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3018                         int64_t msg_ref = 0;
3019                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3020                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3021                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3022                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3023                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3024                 }
3025                 case LDKMessageSendEvent_SendClosingSigned: {
3026                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3027                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3028                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3029                         int64_t msg_ref = 0;
3030                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3031                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3032                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3033                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3034                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3035                 }
3036                 case LDKMessageSendEvent_SendShutdown: {
3037                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3038                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3039                         LDKShutdown msg_var = obj->send_shutdown.msg;
3040                         int64_t msg_ref = 0;
3041                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3042                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3043                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3044                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3045                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3046                 }
3047                 case LDKMessageSendEvent_SendChannelReestablish: {
3048                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3049                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3050                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3051                         int64_t msg_ref = 0;
3052                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3053                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3054                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3055                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3056                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3057                 }
3058                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3059                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3060                         int64_t msg_ref = 0;
3061                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3062                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3063                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3064                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3065                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3066                         int64_t update_msg_ref = 0;
3067                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3068                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3070                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3071                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3072                 }
3073                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
3074                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3075                         int64_t msg_ref = 0;
3076                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3077                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3078                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3079                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3080                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
3081                 }
3082                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3083                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3084                         int64_t msg_ref = 0;
3085                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3086                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3087                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3088                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3089                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3090                 }
3091                 case LDKMessageSendEvent_SendChannelUpdate: {
3092                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3093                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3094                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3095                         int64_t msg_ref = 0;
3096                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3097                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3098                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3099                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3100                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3101                 }
3102                 case LDKMessageSendEvent_HandleError: {
3103                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3104                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3105                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3106                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3107                 }
3108                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3109                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3110                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3111                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3112                         int64_t msg_ref = 0;
3113                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3114                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3115                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3116                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3117                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3118                 }
3119                 case LDKMessageSendEvent_SendShortIdsQuery: {
3120                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3121                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3122                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3123                         int64_t msg_ref = 0;
3124                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3125                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3126                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3127                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3128                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3129                 }
3130                 case LDKMessageSendEvent_SendReplyChannelRange: {
3131                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3132                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3133                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3134                         int64_t msg_ref = 0;
3135                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3136                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3137                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3138                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3139                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3140                 }
3141                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3142                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3143                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3144                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3145                         int64_t msg_ref = 0;
3146                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3147                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3148                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3149                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3150                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3151                 }
3152                 default: abort();
3153         }
3154 }
3155 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3156         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3157         for (size_t i = 0; i < ret.datalen; i++) {
3158                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3159         }
3160         return ret;
3161 }
3162 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3163 CHECK(owner->result_ok);
3164         return FixedPenaltyScorer_clone(&*owner->contents.result);
3165 }
3166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3167         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3168         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3169         int64_t ret_ref = 0;
3170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3173         ret_ref = (uintptr_t)ret_var.inner;
3174         if (ret_var.is_owned) {
3175                 ret_ref |= 1;
3176         }
3177         return ret_ref;
3178 }
3179
3180 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3181 CHECK(!owner->result_ok);
3182         return DecodeError_clone(&*owner->contents.err);
3183 }
3184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3185         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3186         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3187         int64_t ret_ref = 0;
3188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3191         ret_ref = (uintptr_t)ret_var.inner;
3192         if (ret_var.is_owned) {
3193                 ret_ref |= 1;
3194         }
3195         return ret_ref;
3196 }
3197
3198 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3199 CHECK(owner->result_ok);
3200         return ScoringParameters_clone(&*owner->contents.result);
3201 }
3202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3203         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3204         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
3205         int64_t ret_ref = 0;
3206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3209         ret_ref = (uintptr_t)ret_var.inner;
3210         if (ret_var.is_owned) {
3211                 ret_ref |= 1;
3212         }
3213         return ret_ref;
3214 }
3215
3216 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3217 CHECK(!owner->result_ok);
3218         return DecodeError_clone(&*owner->contents.err);
3219 }
3220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3221         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3222         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
3223         int64_t ret_ref = 0;
3224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3227         ret_ref = (uintptr_t)ret_var.inner;
3228         if (ret_var.is_owned) {
3229                 ret_ref |= 1;
3230         }
3231         return ret_ref;
3232 }
3233
3234 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3235 CHECK(owner->result_ok);
3236         return &*owner->contents.result;
3237 }
3238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3239         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3240         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
3241         int64_t ret_ref = 0;
3242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3245         ret_ref = (uintptr_t)ret_var.inner & ~1;
3246         return ret_ref;
3247 }
3248
3249 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3250 CHECK(!owner->result_ok);
3251         return DecodeError_clone(&*owner->contents.err);
3252 }
3253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3254         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3255         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
3256         int64_t ret_ref = 0;
3257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3260         ret_ref = (uintptr_t)ret_var.inner;
3261         if (ret_var.is_owned) {
3262                 ret_ref |= 1;
3263         }
3264         return ret_ref;
3265 }
3266
3267 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3268 CHECK(owner->result_ok);
3269         return &*owner->contents.result;
3270 }
3271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3272         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3273         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3274         int64_t ret_ref = 0;
3275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3278         ret_ref = (uintptr_t)ret_var.inner & ~1;
3279         return ret_ref;
3280 }
3281
3282 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3283 CHECK(!owner->result_ok);
3284         return DecodeError_clone(&*owner->contents.err);
3285 }
3286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3287         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3288         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3289         int64_t ret_ref = 0;
3290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3293         ret_ref = (uintptr_t)ret_var.inner;
3294         if (ret_var.is_owned) {
3295                 ret_ref |= 1;
3296         }
3297         return ret_ref;
3298 }
3299
3300 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3301 CHECK(owner->result_ok);
3302         return InitFeatures_clone(&*owner->contents.result);
3303 }
3304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3305         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3306         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3307         int64_t ret_ref = 0;
3308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3311         ret_ref = (uintptr_t)ret_var.inner;
3312         if (ret_var.is_owned) {
3313                 ret_ref |= 1;
3314         }
3315         return ret_ref;
3316 }
3317
3318 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3319 CHECK(!owner->result_ok);
3320         return DecodeError_clone(&*owner->contents.err);
3321 }
3322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3323         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3324         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3325         int64_t ret_ref = 0;
3326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3329         ret_ref = (uintptr_t)ret_var.inner;
3330         if (ret_var.is_owned) {
3331                 ret_ref |= 1;
3332         }
3333         return ret_ref;
3334 }
3335
3336 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3337 CHECK(owner->result_ok);
3338         return ChannelFeatures_clone(&*owner->contents.result);
3339 }
3340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3341         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3342         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3343         int64_t ret_ref = 0;
3344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3347         ret_ref = (uintptr_t)ret_var.inner;
3348         if (ret_var.is_owned) {
3349                 ret_ref |= 1;
3350         }
3351         return ret_ref;
3352 }
3353
3354 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3355 CHECK(!owner->result_ok);
3356         return DecodeError_clone(&*owner->contents.err);
3357 }
3358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3359         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3360         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3361         int64_t ret_ref = 0;
3362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3365         ret_ref = (uintptr_t)ret_var.inner;
3366         if (ret_var.is_owned) {
3367                 ret_ref |= 1;
3368         }
3369         return ret_ref;
3370 }
3371
3372 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3373 CHECK(owner->result_ok);
3374         return NodeFeatures_clone(&*owner->contents.result);
3375 }
3376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3377         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3378         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3379         int64_t ret_ref = 0;
3380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3383         ret_ref = (uintptr_t)ret_var.inner;
3384         if (ret_var.is_owned) {
3385                 ret_ref |= 1;
3386         }
3387         return ret_ref;
3388 }
3389
3390 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3391 CHECK(!owner->result_ok);
3392         return DecodeError_clone(&*owner->contents.err);
3393 }
3394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3395         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3396         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3397         int64_t ret_ref = 0;
3398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3401         ret_ref = (uintptr_t)ret_var.inner;
3402         if (ret_var.is_owned) {
3403                 ret_ref |= 1;
3404         }
3405         return ret_ref;
3406 }
3407
3408 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3409 CHECK(owner->result_ok);
3410         return InvoiceFeatures_clone(&*owner->contents.result);
3411 }
3412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3413         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3414         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3415         int64_t ret_ref = 0;
3416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3419         ret_ref = (uintptr_t)ret_var.inner;
3420         if (ret_var.is_owned) {
3421                 ret_ref |= 1;
3422         }
3423         return ret_ref;
3424 }
3425
3426 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3427 CHECK(!owner->result_ok);
3428         return DecodeError_clone(&*owner->contents.err);
3429 }
3430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3431         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3432         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3433         int64_t ret_ref = 0;
3434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3437         ret_ref = (uintptr_t)ret_var.inner;
3438         if (ret_var.is_owned) {
3439                 ret_ref |= 1;
3440         }
3441         return ret_ref;
3442 }
3443
3444 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3445 CHECK(owner->result_ok);
3446         return ChannelTypeFeatures_clone(&*owner->contents.result);
3447 }
3448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3449         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3450         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3451         int64_t ret_ref = 0;
3452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3455         ret_ref = (uintptr_t)ret_var.inner;
3456         if (ret_var.is_owned) {
3457                 ret_ref |= 1;
3458         }
3459         return ret_ref;
3460 }
3461
3462 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3463 CHECK(!owner->result_ok);
3464         return DecodeError_clone(&*owner->contents.err);
3465 }
3466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3467         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3468         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3469         int64_t ret_ref = 0;
3470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3473         ret_ref = (uintptr_t)ret_var.inner;
3474         if (ret_var.is_owned) {
3475                 ret_ref |= 1;
3476         }
3477         return ret_ref;
3478 }
3479
3480 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3481 CHECK(owner->result_ok);
3482         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3483 }
3484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3485         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3486         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3487         int64_t ret_ref = 0;
3488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3491         ret_ref = (uintptr_t)ret_var.inner;
3492         if (ret_var.is_owned) {
3493                 ret_ref |= 1;
3494         }
3495         return ret_ref;
3496 }
3497
3498 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3499 CHECK(!owner->result_ok);
3500         return DecodeError_clone(&*owner->contents.err);
3501 }
3502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3503         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3504         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3505         int64_t ret_ref = 0;
3506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3509         ret_ref = (uintptr_t)ret_var.inner;
3510         if (ret_var.is_owned) {
3511                 ret_ref |= 1;
3512         }
3513         return ret_ref;
3514 }
3515
3516 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3517 CHECK(owner->result_ok);
3518         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3519 }
3520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3521         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3522         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3523         int64_t ret_ref = 0;
3524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3527         ret_ref = (uintptr_t)ret_var.inner;
3528         if (ret_var.is_owned) {
3529                 ret_ref |= 1;
3530         }
3531         return ret_ref;
3532 }
3533
3534 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3535 CHECK(!owner->result_ok);
3536         return DecodeError_clone(&*owner->contents.err);
3537 }
3538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3539         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3540         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3541         int64_t ret_ref = 0;
3542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3545         ret_ref = (uintptr_t)ret_var.inner;
3546         if (ret_var.is_owned) {
3547                 ret_ref |= 1;
3548         }
3549         return ret_ref;
3550 }
3551
3552 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3553 CHECK(owner->result_ok);
3554         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3555 }
3556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3557         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3558         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3559         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3560         int64_t ret_ref = (uintptr_t)ret_copy;
3561         return ret_ref;
3562 }
3563
3564 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3565 CHECK(!owner->result_ok);
3566         return DecodeError_clone(&*owner->contents.err);
3567 }
3568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3569         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3570         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3571         int64_t ret_ref = 0;
3572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3575         ret_ref = (uintptr_t)ret_var.inner;
3576         if (ret_var.is_owned) {
3577                 ret_ref |= 1;
3578         }
3579         return ret_ref;
3580 }
3581
3582 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3583         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3584         for (size_t i = 0; i < ret.datalen; i++) {
3585                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3586         }
3587         return ret;
3588 }
3589 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3590         return owner->a;
3591 }
3592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3593         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3594         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
3596         return ret_arr;
3597 }
3598
3599 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3600         return owner->b;
3601 }
3602 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3603         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3604         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3605         jobjectArray ret_arr = NULL;
3606         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
3607         ;
3608         for (size_t i = 0; i < ret_var.datalen; i++) {
3609                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
3610                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
3611                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
3612         }
3613         
3614         return ret_arr;
3615 }
3616
3617 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3618 CHECK(owner->result_ok);
3619         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3620 }
3621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3622         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3623         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3624         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3625         return ((int64_t)ret_conv);
3626 }
3627
3628 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3629 CHECK(!owner->result_ok);
3630         return *owner->contents.err;
3631 }
3632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3633         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3634         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3635 }
3636
3637 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3638 CHECK(owner->result_ok);
3639         return *owner->contents.result;
3640 }
3641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3642         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3643         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
3645         return ret_arr;
3646 }
3647
3648 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3649 CHECK(!owner->result_ok);
3650         return *owner->contents.err;
3651 }
3652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3653         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3654         CResult_SignatureNoneZ_get_err(owner_conv);
3655 }
3656
3657 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3658         return owner->a;
3659 }
3660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3661         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3662         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
3664         return ret_arr;
3665 }
3666
3667 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3668         return owner->b;
3669 }
3670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3671         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3672         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
3674         return ret_arr;
3675 }
3676
3677 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3678 CHECK(owner->result_ok);
3679         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3680 }
3681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3682         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3683         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3684         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3685         return ((int64_t)ret_conv);
3686 }
3687
3688 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3689 CHECK(!owner->result_ok);
3690         return *owner->contents.err;
3691 }
3692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3693         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3694         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3695 }
3696
3697 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3698 CHECK(owner->result_ok);
3699         return *owner->contents.result;
3700 }
3701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3702         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3703         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
3705         return ret_arr;
3706 }
3707
3708 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3709 CHECK(!owner->result_ok);
3710         return *owner->contents.err;
3711 }
3712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3713         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3714         CResult_SecretKeyNoneZ_get_err(owner_conv);
3715 }
3716
3717 typedef struct LDKBaseSign_JCalls {
3718         atomic_size_t refcnt;
3719         JavaVM *vm;
3720         jweak o;
3721         jmethodID get_per_commitment_point_meth;
3722         jmethodID release_commitment_secret_meth;
3723         jmethodID validate_holder_commitment_meth;
3724         jmethodID channel_keys_id_meth;
3725         jmethodID sign_counterparty_commitment_meth;
3726         jmethodID validate_counterparty_revocation_meth;
3727         jmethodID sign_holder_commitment_and_htlcs_meth;
3728         jmethodID sign_justice_revoked_output_meth;
3729         jmethodID sign_justice_revoked_htlc_meth;
3730         jmethodID sign_counterparty_htlc_transaction_meth;
3731         jmethodID sign_closing_transaction_meth;
3732         jmethodID sign_channel_announcement_meth;
3733         jmethodID ready_channel_meth;
3734 } LDKBaseSign_JCalls;
3735 static void LDKBaseSign_JCalls_free(void* this_arg) {
3736         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3737         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3738                 JNIEnv *env;
3739                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3740                 if (get_jenv_res == JNI_EDETACHED) {
3741                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3742                 } else {
3743                         DO_ASSERT(get_jenv_res == JNI_OK);
3744                 }
3745                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3746                 if (get_jenv_res == JNI_EDETACHED) {
3747                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3748                 }
3749                 FREE(j_calls);
3750         }
3751 }
3752 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3753         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3754         JNIEnv *env;
3755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3756         if (get_jenv_res == JNI_EDETACHED) {
3757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3758         } else {
3759                 DO_ASSERT(get_jenv_res == JNI_OK);
3760         }
3761         int64_t idx_conv = idx;
3762         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3763         CHECK(obj != NULL);
3764         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
3765         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3766                 (*env)->ExceptionDescribe(env);
3767                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
3768         }
3769         LDKPublicKey ret_ref;
3770         CHECK((*env)->GetArrayLength(env, ret) == 33);
3771         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3772         if (get_jenv_res == JNI_EDETACHED) {
3773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3774         }
3775         return ret_ref;
3776 }
3777 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3778         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3779         JNIEnv *env;
3780         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3781         if (get_jenv_res == JNI_EDETACHED) {
3782                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3783         } else {
3784                 DO_ASSERT(get_jenv_res == JNI_OK);
3785         }
3786         int64_t idx_conv = idx;
3787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3788         CHECK(obj != NULL);
3789         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
3790         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3791                 (*env)->ExceptionDescribe(env);
3792                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
3793         }
3794         LDKThirtyTwoBytes ret_ref;
3795         CHECK((*env)->GetArrayLength(env, ret) == 32);
3796         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3797         if (get_jenv_res == JNI_EDETACHED) {
3798                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3799         }
3800         return ret_ref;
3801 }
3802 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3803         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3804         JNIEnv *env;
3805         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3806         if (get_jenv_res == JNI_EDETACHED) {
3807                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3808         } else {
3809                 DO_ASSERT(get_jenv_res == JNI_OK);
3810         }
3811         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3812         int64_t holder_tx_ref = 0;
3813         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3814         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3815         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3816         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3817         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3818         if (holder_tx_var.is_owned) {
3819                 holder_tx_ref |= 1;
3820         }
3821         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3822         jobjectArray preimages_arr = NULL;
3823         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3824         ;
3825         for (size_t i = 0; i < preimages_var.datalen; i++) {
3826                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3827                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3828                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3829         }
3830         
3831         FREE(preimages_var.data);
3832         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3833         CHECK(obj != NULL);
3834         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
3835         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3836                 (*env)->ExceptionDescribe(env);
3837                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
3838         }
3839         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3840         CHECK_ACCESS(ret_ptr);
3841         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3842         FREE((void*)ret);
3843         if (get_jenv_res == JNI_EDETACHED) {
3844                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3845         }
3846         return ret_conv;
3847 }
3848 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3849         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3850         JNIEnv *env;
3851         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3852         if (get_jenv_res == JNI_EDETACHED) {
3853                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3854         } else {
3855                 DO_ASSERT(get_jenv_res == JNI_OK);
3856         }
3857         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3858         CHECK(obj != NULL);
3859         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
3860         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3861                 (*env)->ExceptionDescribe(env);
3862                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
3863         }
3864         LDKThirtyTwoBytes ret_ref;
3865         CHECK((*env)->GetArrayLength(env, ret) == 32);
3866         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3867         if (get_jenv_res == JNI_EDETACHED) {
3868                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3869         }
3870         return ret_ref;
3871 }
3872 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3873         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3874         JNIEnv *env;
3875         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3876         if (get_jenv_res == JNI_EDETACHED) {
3877                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3878         } else {
3879                 DO_ASSERT(get_jenv_res == JNI_OK);
3880         }
3881         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3882         int64_t commitment_tx_ref = 0;
3883         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3884         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3885         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3886         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3887         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3888         if (commitment_tx_var.is_owned) {
3889                 commitment_tx_ref |= 1;
3890         }
3891         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3892         jobjectArray preimages_arr = NULL;
3893         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3894         ;
3895         for (size_t i = 0; i < preimages_var.datalen; i++) {
3896                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3897                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3898                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3899         }
3900         
3901         FREE(preimages_var.data);
3902         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3903         CHECK(obj != NULL);
3904         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
3905         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3906                 (*env)->ExceptionDescribe(env);
3907                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3908         }
3909         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3910         CHECK_ACCESS(ret_ptr);
3911         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3912         FREE((void*)ret);
3913         if (get_jenv_res == JNI_EDETACHED) {
3914                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3915         }
3916         return ret_conv;
3917 }
3918 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3919         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3920         JNIEnv *env;
3921         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3922         if (get_jenv_res == JNI_EDETACHED) {
3923                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3924         } else {
3925                 DO_ASSERT(get_jenv_res == JNI_OK);
3926         }
3927         int64_t idx_conv = idx;
3928         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3929         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3930         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3931         CHECK(obj != NULL);
3932         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
3933         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3934                 (*env)->ExceptionDescribe(env);
3935                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3936         }
3937         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3938         CHECK_ACCESS(ret_ptr);
3939         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3940         FREE((void*)ret);
3941         if (get_jenv_res == JNI_EDETACHED) {
3942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3943         }
3944         return ret_conv;
3945 }
3946 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3947         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3948         JNIEnv *env;
3949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3950         if (get_jenv_res == JNI_EDETACHED) {
3951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3952         } else {
3953                 DO_ASSERT(get_jenv_res == JNI_OK);
3954         }
3955         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3956         int64_t commitment_tx_ref = 0;
3957         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3958         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3959         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3960         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3961         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3962         if (commitment_tx_var.is_owned) {
3963                 commitment_tx_ref |= 1;
3964         }
3965         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3966         CHECK(obj != NULL);
3967         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3968         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3969                 (*env)->ExceptionDescribe(env);
3970                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3971         }
3972         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3973         CHECK_ACCESS(ret_ptr);
3974         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3975         FREE((void*)ret);
3976         if (get_jenv_res == JNI_EDETACHED) {
3977                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3978         }
3979         return ret_conv;
3980 }
3981 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]) {
3982         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3983         JNIEnv *env;
3984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3985         if (get_jenv_res == JNI_EDETACHED) {
3986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3987         } else {
3988                 DO_ASSERT(get_jenv_res == JNI_OK);
3989         }
3990         LDKTransaction justice_tx_var = justice_tx;
3991         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3992         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3993         Transaction_free(justice_tx_var);
3994         int64_t input_conv = input;
3995         int64_t amount_conv = amount;
3996         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3997         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3999         CHECK(obj != NULL);
4000         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr);
4001         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4002                 (*env)->ExceptionDescribe(env);
4003                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
4004         }
4005         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4006         CHECK_ACCESS(ret_ptr);
4007         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4008         FREE((void*)ret);
4009         if (get_jenv_res == JNI_EDETACHED) {
4010                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4011         }
4012         return ret_conv;
4013 }
4014 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) {
4015         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4016         JNIEnv *env;
4017         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4018         if (get_jenv_res == JNI_EDETACHED) {
4019                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4020         } else {
4021                 DO_ASSERT(get_jenv_res == JNI_OK);
4022         }
4023         LDKTransaction justice_tx_var = justice_tx;
4024         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4025         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4026         Transaction_free(justice_tx_var);
4027         int64_t input_conv = input;
4028         int64_t amount_conv = amount;
4029         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4030         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4031         LDKHTLCOutputInCommitment htlc_var = *htlc;
4032         int64_t htlc_ref = 0;
4033         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4034         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4035         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4036         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4037         htlc_ref = (uintptr_t)htlc_var.inner;
4038         if (htlc_var.is_owned) {
4039                 htlc_ref |= 1;
4040         }
4041         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4042         CHECK(obj != NULL);
4043         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr, htlc_ref);
4044         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4045                 (*env)->ExceptionDescribe(env);
4046                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4047         }
4048         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4049         CHECK_ACCESS(ret_ptr);
4050         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4051         FREE((void*)ret);
4052         if (get_jenv_res == JNI_EDETACHED) {
4053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4054         }
4055         return ret_conv;
4056 }
4057 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) {
4058         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4059         JNIEnv *env;
4060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4061         if (get_jenv_res == JNI_EDETACHED) {
4062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4063         } else {
4064                 DO_ASSERT(get_jenv_res == JNI_OK);
4065         }
4066         LDKTransaction htlc_tx_var = htlc_tx;
4067         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4068         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4069         Transaction_free(htlc_tx_var);
4070         int64_t input_conv = input;
4071         int64_t amount_conv = amount;
4072         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4073         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4074         LDKHTLCOutputInCommitment htlc_var = *htlc;
4075         int64_t htlc_ref = 0;
4076         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4077         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4078         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4079         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4080         htlc_ref = (uintptr_t)htlc_var.inner;
4081         if (htlc_var.is_owned) {
4082                 htlc_ref |= 1;
4083         }
4084         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4085         CHECK(obj != NULL);
4086         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input_conv, amount_conv, per_commitment_point_arr, htlc_ref);
4087         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4088                 (*env)->ExceptionDescribe(env);
4089                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4090         }
4091         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4092         CHECK_ACCESS(ret_ptr);
4093         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4094         FREE((void*)ret);
4095         if (get_jenv_res == JNI_EDETACHED) {
4096                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4097         }
4098         return ret_conv;
4099 }
4100 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4101         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4102         JNIEnv *env;
4103         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4104         if (get_jenv_res == JNI_EDETACHED) {
4105                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4106         } else {
4107                 DO_ASSERT(get_jenv_res == JNI_OK);
4108         }
4109         LDKClosingTransaction closing_tx_var = *closing_tx;
4110         int64_t closing_tx_ref = 0;
4111         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4112         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4113         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4114         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4115         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4116         if (closing_tx_var.is_owned) {
4117                 closing_tx_ref |= 1;
4118         }
4119         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4120         CHECK(obj != NULL);
4121         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4122         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4123                 (*env)->ExceptionDescribe(env);
4124                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4125         }
4126         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4127         CHECK_ACCESS(ret_ptr);
4128         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4129         FREE((void*)ret);
4130         if (get_jenv_res == JNI_EDETACHED) {
4131                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4132         }
4133         return ret_conv;
4134 }
4135 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4136         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4137         JNIEnv *env;
4138         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4139         if (get_jenv_res == JNI_EDETACHED) {
4140                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4141         } else {
4142                 DO_ASSERT(get_jenv_res == JNI_OK);
4143         }
4144         LDKUnsignedChannelAnnouncement msg_var = *msg;
4145         int64_t msg_ref = 0;
4146         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4147         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4148         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4150         msg_ref = (uintptr_t)msg_var.inner;
4151         if (msg_var.is_owned) {
4152                 msg_ref |= 1;
4153         }
4154         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4155         CHECK(obj != NULL);
4156         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4157         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4158                 (*env)->ExceptionDescribe(env);
4159                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4160         }
4161         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4162         CHECK_ACCESS(ret_ptr);
4163         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4164         FREE((void*)ret);
4165         if (get_jenv_res == JNI_EDETACHED) {
4166                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4167         }
4168         return ret_conv;
4169 }
4170 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4171         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4172         JNIEnv *env;
4173         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4174         if (get_jenv_res == JNI_EDETACHED) {
4175                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4176         } else {
4177                 DO_ASSERT(get_jenv_res == JNI_OK);
4178         }
4179         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4180         int64_t channel_parameters_ref = 0;
4181         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4182         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4183         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4184         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4185         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4186         if (channel_parameters_var.is_owned) {
4187                 channel_parameters_ref |= 1;
4188         }
4189         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4190         CHECK(obj != NULL);
4191         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4192         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4193                 (*env)->ExceptionDescribe(env);
4194                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4195         }
4196         if (get_jenv_res == JNI_EDETACHED) {
4197                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4198         }
4199 }
4200 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4201         jclass c = (*env)->GetObjectClass(env, o);
4202         CHECK(c != NULL);
4203         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4204         atomic_init(&calls->refcnt, 1);
4205         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4206         calls->o = (*env)->NewWeakGlobalRef(env, o);
4207         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4208         CHECK(calls->get_per_commitment_point_meth != NULL);
4209         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4210         CHECK(calls->release_commitment_secret_meth != NULL);
4211         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4212         CHECK(calls->validate_holder_commitment_meth != NULL);
4213         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4214         CHECK(calls->channel_keys_id_meth != NULL);
4215         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4216         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4217         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4218         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4219         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4220         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4221         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4222         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4223         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4224         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4225         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4226         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4227         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4228         CHECK(calls->sign_closing_transaction_meth != NULL);
4229         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4230         CHECK(calls->sign_channel_announcement_meth != NULL);
4231         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4232         CHECK(calls->ready_channel_meth != NULL);
4233
4234         LDKChannelPublicKeys pubkeys_conv;
4235         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4236         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4237         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4238
4239         LDKBaseSign ret = {
4240                 .this_arg = (void*) calls,
4241                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4242                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4243                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4244                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4245                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4246                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4247                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4248                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4249                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4250                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4251                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4252                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4253                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4254                 .free = LDKBaseSign_JCalls_free,
4255                 .pubkeys = pubkeys_conv,
4256                 .set_pubkeys = NULL,
4257         };
4258         return ret;
4259 }
4260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4261         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4262         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
4263         return (uint64_t)res_ptr;
4264 }
4265 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) {
4266         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4267         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4268         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4269         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
4271         return ret_arr;
4272 }
4273
4274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
4275         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4276         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4277         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4278         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
4280         return ret_arr;
4281 }
4282
4283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx, jobjectArray preimages) {
4284         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4285         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4286         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4287         LDKHolderCommitmentTransaction holder_tx_conv;
4288         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4289         holder_tx_conv.is_owned = false;
4290         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4291         LDKCVec_PaymentPreimageZ preimages_constr;
4292         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4293         if (preimages_constr.datalen > 0)
4294                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4295         else
4296                 preimages_constr.data = NULL;
4297         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4298                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4299                 LDKThirtyTwoBytes preimages_conv_8_ref;
4300                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4301                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4302                 preimages_constr.data[i] = preimages_conv_8_ref;
4303         }
4304         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4305         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4306         return (int64_t)ret_conv;
4307 }
4308
4309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4310         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4311         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4312         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4313         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4314         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
4315         return ret_arr;
4316 }
4317
4318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx, jobjectArray preimages) {
4319         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4320         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4321         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4322         LDKCommitmentTransaction commitment_tx_conv;
4323         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4324         commitment_tx_conv.is_owned = false;
4325         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4326         LDKCVec_PaymentPreimageZ preimages_constr;
4327         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4328         if (preimages_constr.datalen > 0)
4329                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4330         else
4331                 preimages_constr.data = NULL;
4332         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4333                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4334                 LDKThirtyTwoBytes preimages_conv_8_ref;
4335                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4336                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4337                 preimages_constr.data[i] = preimages_conv_8_ref;
4338         }
4339         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4340         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4341         return (int64_t)ret_conv;
4342 }
4343
4344 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) {
4345         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4346         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4347         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4348         unsigned char secret_arr[32];
4349         CHECK((*env)->GetArrayLength(env, secret) == 32);
4350         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
4351         unsigned char (*secret_ref)[32] = &secret_arr;
4352         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4353         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4354         return (int64_t)ret_conv;
4355 }
4356
4357 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) {
4358         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4359         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4360         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4361         LDKHolderCommitmentTransaction commitment_tx_conv;
4362         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4363         commitment_tx_conv.is_owned = false;
4364         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4365         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4366         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4367         return (int64_t)ret_conv;
4368 }
4369
4370 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) {
4371         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4373         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4374         LDKTransaction justice_tx_ref;
4375         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4376         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4377         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4378         justice_tx_ref.data_is_owned = true;
4379         unsigned char per_commitment_key_arr[32];
4380         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4381         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4382         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4383         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4384         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4385         return (int64_t)ret_conv;
4386 }
4387
4388 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) {
4389         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4390         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4391         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4392         LDKTransaction justice_tx_ref;
4393         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4394         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4395         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4396         justice_tx_ref.data_is_owned = true;
4397         unsigned char per_commitment_key_arr[32];
4398         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4399         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4400         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4401         LDKHTLCOutputInCommitment htlc_conv;
4402         htlc_conv.inner = (void*)(htlc & (~1));
4403         htlc_conv.is_owned = false;
4404         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4405         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4406         *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);
4407         return (int64_t)ret_conv;
4408 }
4409
4410 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) {
4411         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4412         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4413         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4414         LDKTransaction htlc_tx_ref;
4415         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
4416         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4417         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
4418         htlc_tx_ref.data_is_owned = true;
4419         LDKPublicKey per_commitment_point_ref;
4420         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4421         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4422         LDKHTLCOutputInCommitment htlc_conv;
4423         htlc_conv.inner = (void*)(htlc & (~1));
4424         htlc_conv.is_owned = false;
4425         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4426         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4427         *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);
4428         return (int64_t)ret_conv;
4429 }
4430
4431 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) {
4432         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4433         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4434         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4435         LDKClosingTransaction closing_tx_conv;
4436         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4437         closing_tx_conv.is_owned = false;
4438         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4439         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4440         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4441         return (int64_t)ret_conv;
4442 }
4443
4444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
4445         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4446         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4447         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4448         LDKUnsignedChannelAnnouncement msg_conv;
4449         msg_conv.inner = (void*)(msg & (~1));
4450         msg_conv.is_owned = false;
4451         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4452         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4453         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4454         return (int64_t)ret_conv;
4455 }
4456
4457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
4458         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4459         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4460         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4461         LDKChannelTransactionParameters channel_parameters_conv;
4462         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4463         channel_parameters_conv.is_owned = false;
4464         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4465         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4466 }
4467
4468 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4469         if (this_arg->set_pubkeys != NULL)
4470                 this_arg->set_pubkeys(this_arg);
4471         return this_arg->pubkeys;
4472 }
4473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
4474         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4475         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4476         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4477         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4478         int64_t ret_ref = 0;
4479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4482         ret_ref = (uintptr_t)ret_var.inner;
4483         if (ret_var.is_owned) {
4484                 ret_ref |= 1;
4485         }
4486         return ret_ref;
4487 }
4488
4489 typedef struct LDKSign_JCalls {
4490         atomic_size_t refcnt;
4491         JavaVM *vm;
4492         jweak o;
4493         LDKBaseSign_JCalls* BaseSign;
4494         jmethodID write_meth;
4495 } LDKSign_JCalls;
4496 static void LDKSign_JCalls_free(void* this_arg) {
4497         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4498         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4499                 JNIEnv *env;
4500                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4501                 if (get_jenv_res == JNI_EDETACHED) {
4502                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4503                 } else {
4504                         DO_ASSERT(get_jenv_res == JNI_OK);
4505                 }
4506                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4507                 if (get_jenv_res == JNI_EDETACHED) {
4508                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4509                 }
4510                 FREE(j_calls);
4511         }
4512 }
4513 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4514         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4515         JNIEnv *env;
4516         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4517         if (get_jenv_res == JNI_EDETACHED) {
4518                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4519         } else {
4520                 DO_ASSERT(get_jenv_res == JNI_OK);
4521         }
4522         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4523         CHECK(obj != NULL);
4524         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4525         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4526                 (*env)->ExceptionDescribe(env);
4527                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
4528         }
4529         LDKCVec_u8Z ret_ref;
4530         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4531         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4532         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4533         if (get_jenv_res == JNI_EDETACHED) {
4534                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4535         }
4536         return ret_ref;
4537 }
4538 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4539         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4540         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4541         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4542 }
4543 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4544         jclass c = (*env)->GetObjectClass(env, o);
4545         CHECK(c != NULL);
4546         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4547         atomic_init(&calls->refcnt, 1);
4548         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4549         calls->o = (*env)->NewWeakGlobalRef(env, o);
4550         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4551         CHECK(calls->write_meth != NULL);
4552
4553         LDKChannelPublicKeys pubkeys_conv;
4554         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4555         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4556         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4557
4558         LDKSign ret = {
4559                 .this_arg = (void*) calls,
4560                 .write = write_LDKSign_jcall,
4561                 .cloned = LDKSign_JCalls_cloned,
4562                 .free = LDKSign_JCalls_free,
4563                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
4564         };
4565         calls->BaseSign = ret.BaseSign.this_arg;
4566         return ret;
4567 }
4568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4569         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4570         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
4571         return (uint64_t)res_ptr;
4572 }
4573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
4574         LDKSign *inp = (LDKSign *)(arg & ~1);
4575         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
4576         DO_ASSERT((res_ptr & 1) == 0);
4577         return (int64_t)(res_ptr | 1);
4578 }
4579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4580         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4581         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4582         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4583         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4584         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4585         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4586         CVec_u8Z_free(ret_var);
4587         return ret_arr;
4588 }
4589
4590 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4591 CHECK(owner->result_ok);
4592         return Sign_clone(&*owner->contents.result);
4593 }
4594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4595         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4596         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4597         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4598         return (int64_t)ret_ret;
4599 }
4600
4601 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4602 CHECK(!owner->result_ok);
4603         return DecodeError_clone(&*owner->contents.err);
4604 }
4605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4606         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4607         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4608         int64_t ret_ref = 0;
4609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4612         ret_ref = (uintptr_t)ret_var.inner;
4613         if (ret_var.is_owned) {
4614                 ret_ref |= 1;
4615         }
4616         return ret_ref;
4617 }
4618
4619 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4620 CHECK(owner->result_ok);
4621         return *owner->contents.result;
4622 }
4623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4624         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4625         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
4626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
4627         return ret_arr;
4628 }
4629
4630 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4631 CHECK(!owner->result_ok);
4632         return *owner->contents.err;
4633 }
4634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4635         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4636         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4637 }
4638
4639 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4640         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4641         for (size_t i = 0; i < ret.datalen; i++) {
4642                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4643         }
4644         return ret;
4645 }
4646 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4647 CHECK(owner->result_ok);
4648         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4649 }
4650 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4651         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4652         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4653         jobjectArray ret_arr = NULL;
4654         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4655         ;
4656         for (size_t i = 0; i < ret_var.datalen; i++) {
4657                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
4658                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
4659                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
4660                 CVec_u8Z_free(ret_conv_8_var);
4661                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4662         }
4663         
4664         FREE(ret_var.data);
4665         return ret_arr;
4666 }
4667
4668 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4669 CHECK(!owner->result_ok);
4670         return *owner->contents.err;
4671 }
4672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4673         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4674         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4675 }
4676
4677 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4678 CHECK(owner->result_ok);
4679         return InMemorySigner_clone(&*owner->contents.result);
4680 }
4681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4682         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4683         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4684         int64_t ret_ref = 0;
4685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4688         ret_ref = (uintptr_t)ret_var.inner;
4689         if (ret_var.is_owned) {
4690                 ret_ref |= 1;
4691         }
4692         return ret_ref;
4693 }
4694
4695 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4696 CHECK(!owner->result_ok);
4697         return DecodeError_clone(&*owner->contents.err);
4698 }
4699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4700         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4701         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4702         int64_t ret_ref = 0;
4703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4706         ret_ref = (uintptr_t)ret_var.inner;
4707         if (ret_var.is_owned) {
4708                 ret_ref |= 1;
4709         }
4710         return ret_ref;
4711 }
4712
4713 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4714         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4715         for (size_t i = 0; i < ret.datalen; i++) {
4716                 ret.data[i] = TxOut_clone(&orig->data[i]);
4717         }
4718         return ret;
4719 }
4720 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4721 CHECK(owner->result_ok);
4722         return *owner->contents.result;
4723 }
4724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4725         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4726         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4727         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4728         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4729         return ret_arr;
4730 }
4731
4732 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4733 CHECK(!owner->result_ok);
4734         return *owner->contents.err;
4735 }
4736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4737         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4738         CResult_TransactionNoneZ_get_err(owner_conv);
4739 }
4740
4741 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4742         return ThirtyTwoBytes_clone(&owner->a);
4743 }
4744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4745         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4746         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
4748         return ret_arr;
4749 }
4750
4751 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4752         return ChannelMonitor_clone(&owner->b);
4753 }
4754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4755         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4756         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
4757         int64_t ret_ref = 0;
4758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4761         ret_ref = (uintptr_t)ret_var.inner;
4762         if (ret_var.is_owned) {
4763                 ret_ref |= 1;
4764         }
4765         return ret_ref;
4766 }
4767
4768 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
4769         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
4770         for (size_t i = 0; i < ret.datalen; i++) {
4771                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
4772         }
4773         return ret;
4774 }
4775 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4776 CHECK(owner->result_ok);
4777         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
4778 }
4779 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4780         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4781         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
4782         int64_tArray ret_arr = NULL;
4783         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4784         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4785         for (size_t j = 0; j < ret_var.datalen; j++) {
4786                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4787                 *ret_conv_35_conv = ret_var.data[j];
4788                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
4789         }
4790         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4791         FREE(ret_var.data);
4792         return ret_arr;
4793 }
4794
4795 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4796 CHECK(!owner->result_ok);
4797         return *owner->contents.err;
4798 }
4799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4800         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4801         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
4802         return ret_conv;
4803 }
4804
4805 static jclass LDKCOption_u16Z_Some_class = NULL;
4806 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
4807 static jclass LDKCOption_u16Z_None_class = NULL;
4808 static jmethodID LDKCOption_u16Z_None_meth = NULL;
4809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
4810         LDKCOption_u16Z_Some_class =
4811                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
4812         CHECK(LDKCOption_u16Z_Some_class != NULL);
4813         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
4814         CHECK(LDKCOption_u16Z_Some_meth != NULL);
4815         LDKCOption_u16Z_None_class =
4816                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
4817         CHECK(LDKCOption_u16Z_None_class != NULL);
4818         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
4819         CHECK(LDKCOption_u16Z_None_meth != NULL);
4820 }
4821 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4822         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4823         switch(obj->tag) {
4824                 case LDKCOption_u16Z_Some: {
4825                         int16_t some_conv = obj->some;
4826                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
4827                 }
4828                 case LDKCOption_u16Z_None: {
4829                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
4830                 }
4831                 default: abort();
4832         }
4833 }
4834 static jclass LDKAPIError_APIMisuseError_class = NULL;
4835 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4836 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4837 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4838 static jclass LDKAPIError_RouteError_class = NULL;
4839 static jmethodID LDKAPIError_RouteError_meth = NULL;
4840 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4841 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4842 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4843 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4844 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
4845 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
4846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4847         LDKAPIError_APIMisuseError_class =
4848                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
4849         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4850         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
4851         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4852         LDKAPIError_FeeRateTooHigh_class =
4853                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
4854         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4855         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
4856         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4857         LDKAPIError_RouteError_class =
4858                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
4859         CHECK(LDKAPIError_RouteError_class != NULL);
4860         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4861         CHECK(LDKAPIError_RouteError_meth != NULL);
4862         LDKAPIError_ChannelUnavailable_class =
4863                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
4864         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4865         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
4866         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4867         LDKAPIError_MonitorUpdateFailed_class =
4868                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
4869         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4870         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4871         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4872         LDKAPIError_IncompatibleShutdownScript_class =
4873                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
4874         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
4875         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
4876         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
4877 }
4878 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4879         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4880         switch(obj->tag) {
4881                 case LDKAPIError_APIMisuseError: {
4882                         LDKStr err_str = obj->api_misuse_error.err;
4883                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4884                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
4885                 }
4886                 case LDKAPIError_FeeRateTooHigh: {
4887                         LDKStr err_str = obj->fee_rate_too_high.err;
4888                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4889                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4890                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
4891                 }
4892                 case LDKAPIError_RouteError: {
4893                         LDKStr err_str = obj->route_error.err;
4894                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4895                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4896                 }
4897                 case LDKAPIError_ChannelUnavailable: {
4898                         LDKStr err_str = obj->channel_unavailable.err;
4899                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4900                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
4901                 }
4902                 case LDKAPIError_MonitorUpdateFailed: {
4903                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4904                 }
4905                 case LDKAPIError_IncompatibleShutdownScript: {
4906                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4907                         int64_t script_ref = 0;
4908                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4909                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4910                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4911                         script_ref = (uintptr_t)script_var.inner & ~1;
4912                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
4913                 }
4914                 default: abort();
4915         }
4916 }
4917 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4918 CHECK(owner->result_ok);
4919         return *owner->contents.result;
4920 }
4921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4922         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4923         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4924 }
4925
4926 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4927 CHECK(!owner->result_ok);
4928         return APIError_clone(&*owner->contents.err);
4929 }
4930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4931         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4932         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4933         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4934         int64_t ret_ref = (uintptr_t)ret_copy;
4935         return ret_ref;
4936 }
4937
4938 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4939         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4940         for (size_t i = 0; i < ret.datalen; i++) {
4941                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4942         }
4943         return ret;
4944 }
4945 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4946         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4947         for (size_t i = 0; i < ret.datalen; i++) {
4948                 ret.data[i] = APIError_clone(&orig->data[i]);
4949         }
4950         return ret;
4951 }
4952 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4953 CHECK(owner->result_ok);
4954         return ThirtyTwoBytes_clone(&*owner->contents.result);
4955 }
4956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4957         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4958         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
4960         return ret_arr;
4961 }
4962
4963 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4964 CHECK(!owner->result_ok);
4965         return APIError_clone(&*owner->contents.err);
4966 }
4967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4968         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4969         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4970         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4971         int64_t ret_ref = (uintptr_t)ret_copy;
4972         return ret_ref;
4973 }
4974
4975 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4976 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4977 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4978 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4979 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4980 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4981 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4982 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4984         LDKPaymentSendFailure_ParameterError_class =
4985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
4986         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4987         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4988         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4989         LDKPaymentSendFailure_PathParameterError_class =
4990                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
4991         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4992         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4993         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4994         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4995                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4996         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4997         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4998         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4999         LDKPaymentSendFailure_PartialFailure_class =
5000                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
5001         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
5002         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
5003         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
5004 }
5005 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5006         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5007         switch(obj->tag) {
5008                 case LDKPaymentSendFailure_ParameterError: {
5009                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5010                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
5011                 }
5012                 case LDKPaymentSendFailure_PathParameterError: {
5013                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5014                         int64_tArray path_parameter_error_arr = NULL;
5015                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
5016                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
5017                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5018                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5019                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5020                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5021                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
5022                         }
5023                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
5024                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
5025                 }
5026                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
5027                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5028                         int64_tArray all_failed_retry_safe_arr = NULL;
5029                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5030                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5031                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5032                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5033                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5034                         }
5035                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5036                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5037                 }
5038                 case LDKPaymentSendFailure_PartialFailure: {
5039                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5040                         int64_tArray results_arr = NULL;
5041                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5042                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5043                         for (size_t w = 0; w < results_var.datalen; w++) {
5044                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5045                                 *results_conv_22_conv = results_var.data[w];
5046                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5047                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
5048                         }
5049                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5050                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5051                         int64_t failed_paths_retry_ref = 0;
5052                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
5053                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5054                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5055                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5056                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
5057                         }
5058                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5059                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5060                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5061                 }
5062                 default: abort();
5063         }
5064 }
5065 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5066 CHECK(owner->result_ok);
5067         return ThirtyTwoBytes_clone(&*owner->contents.result);
5068 }
5069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5070         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5071         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5072         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5073         return ret_arr;
5074 }
5075
5076 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5077 CHECK(!owner->result_ok);
5078         return PaymentSendFailure_clone(&*owner->contents.err);
5079 }
5080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5081         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5082         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5083         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5084         int64_t ret_ref = (uintptr_t)ret_copy;
5085         return ret_ref;
5086 }
5087
5088 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5089 CHECK(owner->result_ok);
5090         return *owner->contents.result;
5091 }
5092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5093         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5094         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5095 }
5096
5097 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5098 CHECK(!owner->result_ok);
5099         return PaymentSendFailure_clone(&*owner->contents.err);
5100 }
5101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5102         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5103         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5104         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5105         int64_t ret_ref = (uintptr_t)ret_copy;
5106         return ret_ref;
5107 }
5108
5109 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5110         return ThirtyTwoBytes_clone(&owner->a);
5111 }
5112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5113         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5114         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5116         return ret_arr;
5117 }
5118
5119 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5120         return ThirtyTwoBytes_clone(&owner->b);
5121 }
5122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5123         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5124         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5126         return ret_arr;
5127 }
5128
5129 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5130 CHECK(owner->result_ok);
5131         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5132 }
5133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5134         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5135         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5136         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5137         return ((int64_t)ret_conv);
5138 }
5139
5140 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5141 CHECK(!owner->result_ok);
5142         return PaymentSendFailure_clone(&*owner->contents.err);
5143 }
5144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5145         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5146         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5147         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5148         int64_t ret_ref = (uintptr_t)ret_copy;
5149         return ret_ref;
5150 }
5151
5152 static jclass LDKNetAddress_IPv4_class = NULL;
5153 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5154 static jclass LDKNetAddress_IPv6_class = NULL;
5155 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5156 static jclass LDKNetAddress_OnionV2_class = NULL;
5157 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5158 static jclass LDKNetAddress_OnionV3_class = NULL;
5159 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5161         LDKNetAddress_IPv4_class =
5162                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5163         CHECK(LDKNetAddress_IPv4_class != NULL);
5164         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5165         CHECK(LDKNetAddress_IPv4_meth != NULL);
5166         LDKNetAddress_IPv6_class =
5167                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5168         CHECK(LDKNetAddress_IPv6_class != NULL);
5169         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5170         CHECK(LDKNetAddress_IPv6_meth != NULL);
5171         LDKNetAddress_OnionV2_class =
5172                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5173         CHECK(LDKNetAddress_OnionV2_class != NULL);
5174         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5175         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5176         LDKNetAddress_OnionV3_class =
5177                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5178         CHECK(LDKNetAddress_OnionV3_class != NULL);
5179         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5180         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5181 }
5182 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5183         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
5184         switch(obj->tag) {
5185                 case LDKNetAddress_IPv4: {
5186                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5187                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5188                         int16_t port_conv = obj->i_pv4.port;
5189                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
5190                 }
5191                 case LDKNetAddress_IPv6: {
5192                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5193                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5194                         int16_t port_conv = obj->i_pv6.port;
5195                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
5196                 }
5197                 case LDKNetAddress_OnionV2: {
5198                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5199                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5200                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5201                 }
5202                 case LDKNetAddress_OnionV3: {
5203                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5204                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5205                         int16_t checksum_conv = obj->onion_v3.checksum;
5206                         int8_t version_conv = obj->onion_v3.version;
5207                         int16_t port_conv = obj->onion_v3.port;
5208                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
5209                 }
5210                 default: abort();
5211         }
5212 }
5213 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5214         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5215         for (size_t i = 0; i < ret.datalen; i++) {
5216                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5217         }
5218         return ret;
5219 }
5220 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5221         return ThirtyTwoBytes_clone(&owner->a);
5222 }
5223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5224         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5225         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5227         return ret_arr;
5228 }
5229
5230 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5231         return ThirtyTwoBytes_clone(&owner->b);
5232 }
5233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5234         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5235         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5237         return ret_arr;
5238 }
5239
5240 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5241 CHECK(owner->result_ok);
5242         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5243 }
5244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5245         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5246         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5247         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5248         return ((int64_t)ret_conv);
5249 }
5250
5251 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5252 CHECK(!owner->result_ok);
5253         return *owner->contents.err;
5254 }
5255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5256         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5257         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5258 }
5259
5260 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5261 CHECK(owner->result_ok);
5262         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5263 }
5264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5265         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5266         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5267         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5268         return ((int64_t)ret_conv);
5269 }
5270
5271 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5272 CHECK(!owner->result_ok);
5273         return APIError_clone(&*owner->contents.err);
5274 }
5275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5276         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5277         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5278         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5279         int64_t ret_ref = (uintptr_t)ret_copy;
5280         return ret_ref;
5281 }
5282
5283 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5284 CHECK(owner->result_ok);
5285         return ThirtyTwoBytes_clone(&*owner->contents.result);
5286 }
5287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5288         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5291         return ret_arr;
5292 }
5293
5294 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5295 CHECK(!owner->result_ok);
5296         return *owner->contents.err;
5297 }
5298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5299         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5300         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5301 }
5302
5303 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5304 CHECK(owner->result_ok);
5305         return ThirtyTwoBytes_clone(&*owner->contents.result);
5306 }
5307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5308         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5309         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5311         return ret_arr;
5312 }
5313
5314 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5315 CHECK(!owner->result_ok);
5316         return APIError_clone(&*owner->contents.err);
5317 }
5318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5319         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5320         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5321         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5322         int64_t ret_ref = (uintptr_t)ret_copy;
5323         return ret_ref;
5324 }
5325
5326 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5327 CHECK(owner->result_ok);
5328         return ThirtyTwoBytes_clone(&*owner->contents.result);
5329 }
5330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5331         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5332         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5333         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
5334         return ret_arr;
5335 }
5336
5337 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5338 CHECK(!owner->result_ok);
5339         return APIError_clone(&*owner->contents.err);
5340 }
5341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5342         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5343         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5344         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5345         int64_t ret_ref = (uintptr_t)ret_copy;
5346         return ret_ref;
5347 }
5348
5349 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5350 CHECK(owner->result_ok);
5351         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5352 }
5353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5354         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5355         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5356         int64_t ret_ref = 0;
5357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5360         ret_ref = (uintptr_t)ret_var.inner;
5361         if (ret_var.is_owned) {
5362                 ret_ref |= 1;
5363         }
5364         return ret_ref;
5365 }
5366
5367 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5368 CHECK(!owner->result_ok);
5369         return DecodeError_clone(&*owner->contents.err);
5370 }
5371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5372         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5373         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5374         int64_t ret_ref = 0;
5375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5378         ret_ref = (uintptr_t)ret_var.inner;
5379         if (ret_var.is_owned) {
5380                 ret_ref |= 1;
5381         }
5382         return ret_ref;
5383 }
5384
5385 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5386 CHECK(owner->result_ok);
5387         return ChannelCounterparty_clone(&*owner->contents.result);
5388 }
5389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5390         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5391         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5392         int64_t ret_ref = 0;
5393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5396         ret_ref = (uintptr_t)ret_var.inner;
5397         if (ret_var.is_owned) {
5398                 ret_ref |= 1;
5399         }
5400         return ret_ref;
5401 }
5402
5403 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5404 CHECK(!owner->result_ok);
5405         return DecodeError_clone(&*owner->contents.err);
5406 }
5407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5408         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5409         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5410         int64_t ret_ref = 0;
5411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5414         ret_ref = (uintptr_t)ret_var.inner;
5415         if (ret_var.is_owned) {
5416                 ret_ref |= 1;
5417         }
5418         return ret_ref;
5419 }
5420
5421 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5422 CHECK(owner->result_ok);
5423         return ChannelDetails_clone(&*owner->contents.result);
5424 }
5425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5426         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5427         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5428         int64_t ret_ref = 0;
5429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5432         ret_ref = (uintptr_t)ret_var.inner;
5433         if (ret_var.is_owned) {
5434                 ret_ref |= 1;
5435         }
5436         return ret_ref;
5437 }
5438
5439 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5440 CHECK(!owner->result_ok);
5441         return DecodeError_clone(&*owner->contents.err);
5442 }
5443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5444         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5445         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5446         int64_t ret_ref = 0;
5447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5450         ret_ref = (uintptr_t)ret_var.inner;
5451         if (ret_var.is_owned) {
5452                 ret_ref |= 1;
5453         }
5454         return ret_ref;
5455 }
5456
5457 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5458 CHECK(owner->result_ok);
5459         return PhantomRouteHints_clone(&*owner->contents.result);
5460 }
5461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5462         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5463         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5464         int64_t ret_ref = 0;
5465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5468         ret_ref = (uintptr_t)ret_var.inner;
5469         if (ret_var.is_owned) {
5470                 ret_ref |= 1;
5471         }
5472         return ret_ref;
5473 }
5474
5475 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5476 CHECK(!owner->result_ok);
5477         return DecodeError_clone(&*owner->contents.err);
5478 }
5479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5480         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5481         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5482         int64_t ret_ref = 0;
5483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5486         ret_ref = (uintptr_t)ret_var.inner;
5487         if (ret_var.is_owned) {
5488                 ret_ref |= 1;
5489         }
5490         return ret_ref;
5491 }
5492
5493 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5494         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5495         for (size_t i = 0; i < ret.datalen; i++) {
5496                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5497         }
5498         return ret;
5499 }
5500 typedef struct LDKWatch_JCalls {
5501         atomic_size_t refcnt;
5502         JavaVM *vm;
5503         jweak o;
5504         jmethodID watch_channel_meth;
5505         jmethodID update_channel_meth;
5506         jmethodID release_pending_monitor_events_meth;
5507 } LDKWatch_JCalls;
5508 static void LDKWatch_JCalls_free(void* this_arg) {
5509         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5510         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5511                 JNIEnv *env;
5512                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5513                 if (get_jenv_res == JNI_EDETACHED) {
5514                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5515                 } else {
5516                         DO_ASSERT(get_jenv_res == JNI_OK);
5517                 }
5518                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5519                 if (get_jenv_res == JNI_EDETACHED) {
5520                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5521                 }
5522                 FREE(j_calls);
5523         }
5524 }
5525 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5526         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5527         JNIEnv *env;
5528         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5529         if (get_jenv_res == JNI_EDETACHED) {
5530                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5531         } else {
5532                 DO_ASSERT(get_jenv_res == JNI_OK);
5533         }
5534         LDKOutPoint funding_txo_var = funding_txo;
5535         int64_t funding_txo_ref = 0;
5536         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5537         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5538         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5539         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5540         if (funding_txo_var.is_owned) {
5541                 funding_txo_ref |= 1;
5542         }
5543         LDKChannelMonitor monitor_var = monitor;
5544         int64_t monitor_ref = 0;
5545         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5546         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5547         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5548         monitor_ref = (uintptr_t)monitor_var.inner;
5549         if (monitor_var.is_owned) {
5550                 monitor_ref |= 1;
5551         }
5552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5553         CHECK(obj != NULL);
5554         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
5555         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5556                 (*env)->ExceptionDescribe(env);
5557                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
5558         }
5559         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5560         CHECK_ACCESS(ret_ptr);
5561         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5562         FREE((void*)ret);
5563         if (get_jenv_res == JNI_EDETACHED) {
5564                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5565         }
5566         return ret_conv;
5567 }
5568 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5569         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5570         JNIEnv *env;
5571         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5572         if (get_jenv_res == JNI_EDETACHED) {
5573                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5574         } else {
5575                 DO_ASSERT(get_jenv_res == JNI_OK);
5576         }
5577         LDKOutPoint funding_txo_var = funding_txo;
5578         int64_t funding_txo_ref = 0;
5579         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5580         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5581         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5582         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5583         if (funding_txo_var.is_owned) {
5584                 funding_txo_ref |= 1;
5585         }
5586         LDKChannelMonitorUpdate update_var = update;
5587         int64_t update_ref = 0;
5588         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5589         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5590         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5591         update_ref = (uintptr_t)update_var.inner;
5592         if (update_var.is_owned) {
5593                 update_ref |= 1;
5594         }
5595         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5596         CHECK(obj != NULL);
5597         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
5598         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5599                 (*env)->ExceptionDescribe(env);
5600                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
5601         }
5602         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5603         CHECK_ACCESS(ret_ptr);
5604         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5605         FREE((void*)ret);
5606         if (get_jenv_res == JNI_EDETACHED) {
5607                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5608         }
5609         return ret_conv;
5610 }
5611 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5612         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5613         JNIEnv *env;
5614         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5615         if (get_jenv_res == JNI_EDETACHED) {
5616                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5617         } else {
5618                 DO_ASSERT(get_jenv_res == JNI_OK);
5619         }
5620         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5621         CHECK(obj != NULL);
5622         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
5623         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5624                 (*env)->ExceptionDescribe(env);
5625                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
5626         }
5627         LDKCVec_MonitorEventZ ret_constr;
5628         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5629         if (ret_constr.datalen > 0)
5630                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
5631         else
5632                 ret_constr.data = NULL;
5633         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5634         for (size_t o = 0; o < ret_constr.datalen; o++) {
5635                 int64_t ret_conv_14 = ret_vals[o];
5636                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
5637                 CHECK_ACCESS(ret_conv_14_ptr);
5638                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
5639                 FREE((void*)ret_conv_14);
5640                 ret_constr.data[o] = ret_conv_14_conv;
5641         }
5642         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5643         if (get_jenv_res == JNI_EDETACHED) {
5644                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5645         }
5646         return ret_constr;
5647 }
5648 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5649         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5650         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5651 }
5652 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
5653         jclass c = (*env)->GetObjectClass(env, o);
5654         CHECK(c != NULL);
5655         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5656         atomic_init(&calls->refcnt, 1);
5657         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5658         calls->o = (*env)->NewWeakGlobalRef(env, o);
5659         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
5660         CHECK(calls->watch_channel_meth != NULL);
5661         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
5662         CHECK(calls->update_channel_meth != NULL);
5663         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
5664         CHECK(calls->release_pending_monitor_events_meth != NULL);
5665
5666         LDKWatch ret = {
5667                 .this_arg = (void*) calls,
5668                 .watch_channel = watch_channel_LDKWatch_jcall,
5669                 .update_channel = update_channel_LDKWatch_jcall,
5670                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5671                 .free = LDKWatch_JCalls_free,
5672         };
5673         return ret;
5674 }
5675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
5676         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5677         *res_ptr = LDKWatch_init(env, clz, o);
5678         return (uint64_t)res_ptr;
5679 }
5680 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) {
5681         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5682         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5683         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5684         LDKOutPoint funding_txo_conv;
5685         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5686         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5687         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5688         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5689         LDKChannelMonitor monitor_conv;
5690         monitor_conv.inner = (void*)(monitor & (~1));
5691         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5692         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5693         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5694         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5695         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5696         return (int64_t)ret_conv;
5697 }
5698
5699 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) {
5700         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5701         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5702         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5703         LDKOutPoint funding_txo_conv;
5704         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5705         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5706         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5707         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5708         LDKChannelMonitorUpdate update_conv;
5709         update_conv.inner = (void*)(update & (~1));
5710         update_conv.is_owned = (update & 1) || (update == 0);
5711         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5712         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5713         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5714         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5715         return (int64_t)ret_conv;
5716 }
5717
5718 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5719         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5720         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5721         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5722         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5723         int64_tArray ret_arr = NULL;
5724         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5725         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5726         for (size_t o = 0; o < ret_var.datalen; o++) {
5727                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
5728                 *ret_conv_14_copy = ret_var.data[o];
5729                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
5730                 ret_arr_ptr[o] = ret_conv_14_ref;
5731         }
5732         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5733         FREE(ret_var.data);
5734         return ret_arr;
5735 }
5736
5737 typedef struct LDKBroadcasterInterface_JCalls {
5738         atomic_size_t refcnt;
5739         JavaVM *vm;
5740         jweak o;
5741         jmethodID broadcast_transaction_meth;
5742 } LDKBroadcasterInterface_JCalls;
5743 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5744         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5745         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5746                 JNIEnv *env;
5747                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5748                 if (get_jenv_res == JNI_EDETACHED) {
5749                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5750                 } else {
5751                         DO_ASSERT(get_jenv_res == JNI_OK);
5752                 }
5753                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5754                 if (get_jenv_res == JNI_EDETACHED) {
5755                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5756                 }
5757                 FREE(j_calls);
5758         }
5759 }
5760 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5761         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5762         JNIEnv *env;
5763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5764         if (get_jenv_res == JNI_EDETACHED) {
5765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5766         } else {
5767                 DO_ASSERT(get_jenv_res == JNI_OK);
5768         }
5769         LDKTransaction tx_var = tx;
5770         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
5771         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
5772         Transaction_free(tx_var);
5773         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5774         CHECK(obj != NULL);
5775         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
5776         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5777                 (*env)->ExceptionDescribe(env);
5778                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
5779         }
5780         if (get_jenv_res == JNI_EDETACHED) {
5781                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5782         }
5783 }
5784 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5785         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5786         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5787 }
5788 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
5789         jclass c = (*env)->GetObjectClass(env, o);
5790         CHECK(c != NULL);
5791         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5792         atomic_init(&calls->refcnt, 1);
5793         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5794         calls->o = (*env)->NewWeakGlobalRef(env, o);
5795         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
5796         CHECK(calls->broadcast_transaction_meth != NULL);
5797
5798         LDKBroadcasterInterface ret = {
5799                 .this_arg = (void*) calls,
5800                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5801                 .free = LDKBroadcasterInterface_JCalls_free,
5802         };
5803         return ret;
5804 }
5805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5806         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5807         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
5808         return (uint64_t)res_ptr;
5809 }
5810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
5811         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5812         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5813         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5814         LDKTransaction tx_ref;
5815         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
5816         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5817         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
5818         tx_ref.data_is_owned = true;
5819         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5820 }
5821
5822 typedef struct LDKKeysInterface_JCalls {
5823         atomic_size_t refcnt;
5824         JavaVM *vm;
5825         jweak o;
5826         jmethodID get_node_secret_meth;
5827         jmethodID get_destination_script_meth;
5828         jmethodID get_shutdown_scriptpubkey_meth;
5829         jmethodID get_channel_signer_meth;
5830         jmethodID get_secure_random_bytes_meth;
5831         jmethodID read_chan_signer_meth;
5832         jmethodID sign_invoice_meth;
5833         jmethodID get_inbound_payment_key_material_meth;
5834 } LDKKeysInterface_JCalls;
5835 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5836         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5837         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5838                 JNIEnv *env;
5839                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5840                 if (get_jenv_res == JNI_EDETACHED) {
5841                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5842                 } else {
5843                         DO_ASSERT(get_jenv_res == JNI_OK);
5844                 }
5845                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5846                 if (get_jenv_res == JNI_EDETACHED) {
5847                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5848                 }
5849                 FREE(j_calls);
5850         }
5851 }
5852 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5853         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5854         JNIEnv *env;
5855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5856         if (get_jenv_res == JNI_EDETACHED) {
5857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5858         } else {
5859                 DO_ASSERT(get_jenv_res == JNI_OK);
5860         }
5861         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
5862         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5863         CHECK(obj != NULL);
5864         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
5865         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5866                 (*env)->ExceptionDescribe(env);
5867                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
5868         }
5869         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5870         CHECK_ACCESS(ret_ptr);
5871         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5872         FREE((void*)ret);
5873         if (get_jenv_res == JNI_EDETACHED) {
5874                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5875         }
5876         return ret_conv;
5877 }
5878 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5879         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5880         JNIEnv *env;
5881         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5882         if (get_jenv_res == JNI_EDETACHED) {
5883                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5884         } else {
5885                 DO_ASSERT(get_jenv_res == JNI_OK);
5886         }
5887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5888         CHECK(obj != NULL);
5889         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
5890         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5891                 (*env)->ExceptionDescribe(env);
5892                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
5893         }
5894         LDKCVec_u8Z ret_ref;
5895         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5896         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5897         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5898         if (get_jenv_res == JNI_EDETACHED) {
5899                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5900         }
5901         return ret_ref;
5902 }
5903 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5904         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5905         JNIEnv *env;
5906         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5907         if (get_jenv_res == JNI_EDETACHED) {
5908                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5909         } else {
5910                 DO_ASSERT(get_jenv_res == JNI_OK);
5911         }
5912         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5913         CHECK(obj != NULL);
5914         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
5915         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5916                 (*env)->ExceptionDescribe(env);
5917                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
5918         }
5919         LDKShutdownScript ret_conv;
5920         ret_conv.inner = (void*)(ret & (~1));
5921         ret_conv.is_owned = (ret & 1) || (ret == 0);
5922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5923         if (get_jenv_res == JNI_EDETACHED) {
5924                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5925         }
5926         return ret_conv;
5927 }
5928 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5929         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5930         JNIEnv *env;
5931         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5932         if (get_jenv_res == JNI_EDETACHED) {
5933                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5934         } else {
5935                 DO_ASSERT(get_jenv_res == JNI_OK);
5936         }
5937         jboolean inbound_conv = inbound;
5938         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5939         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5940         CHECK(obj != NULL);
5941         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
5942         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5943                 (*env)->ExceptionDescribe(env);
5944                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
5945         }
5946         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5947         CHECK_ACCESS(ret_ptr);
5948         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5949         FREE((void*)ret);
5950         if (get_jenv_res == JNI_EDETACHED) {
5951                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5952         }
5953         return ret_conv;
5954 }
5955 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5956         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5957         JNIEnv *env;
5958         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5959         if (get_jenv_res == JNI_EDETACHED) {
5960                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5961         } else {
5962                 DO_ASSERT(get_jenv_res == JNI_OK);
5963         }
5964         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5965         CHECK(obj != NULL);
5966         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
5967         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5968                 (*env)->ExceptionDescribe(env);
5969                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
5970         }
5971         LDKThirtyTwoBytes ret_ref;
5972         CHECK((*env)->GetArrayLength(env, ret) == 32);
5973         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5974         if (get_jenv_res == JNI_EDETACHED) {
5975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5976         }
5977         return ret_ref;
5978 }
5979 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5980         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5981         JNIEnv *env;
5982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5983         if (get_jenv_res == JNI_EDETACHED) {
5984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5985         } else {
5986                 DO_ASSERT(get_jenv_res == JNI_OK);
5987         }
5988         LDKu8slice reader_var = reader;
5989         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
5990         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
5991         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5992         CHECK(obj != NULL);
5993         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
5994         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5995                 (*env)->ExceptionDescribe(env);
5996                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
5997         }
5998         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5999         CHECK_ACCESS(ret_ptr);
6000         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6001         FREE((void*)ret);
6002         if (get_jenv_res == JNI_EDETACHED) {
6003                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6004         }
6005         return ret_conv;
6006 }
6007 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6008         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6009         JNIEnv *env;
6010         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6011         if (get_jenv_res == JNI_EDETACHED) {
6012                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6013         } else {
6014                 DO_ASSERT(get_jenv_res == JNI_OK);
6015         }
6016         LDKu8slice hrp_bytes_var = hrp_bytes;
6017         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6018         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6019         LDKCVec_u5Z invoice_data_var = invoice_data;
6020         jobjectArray invoice_data_arr = NULL;
6021         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
6022         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
6023         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6024                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6025                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6026         }
6027         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
6028         FREE(invoice_data_var.data);
6029         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
6030         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6031         CHECK(obj != NULL);
6032         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
6033         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6034                 (*env)->ExceptionDescribe(env);
6035                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6036         }
6037         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6038         CHECK_ACCESS(ret_ptr);
6039         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6040         FREE((void*)ret);
6041         if (get_jenv_res == JNI_EDETACHED) {
6042                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6043         }
6044         return ret_conv;
6045 }
6046 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6047         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6048         JNIEnv *env;
6049         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6050         if (get_jenv_res == JNI_EDETACHED) {
6051                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6052         } else {
6053                 DO_ASSERT(get_jenv_res == JNI_OK);
6054         }
6055         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6056         CHECK(obj != NULL);
6057         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6058         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6059                 (*env)->ExceptionDescribe(env);
6060                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6061         }
6062         LDKThirtyTwoBytes ret_ref;
6063         CHECK((*env)->GetArrayLength(env, ret) == 32);
6064         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6065         if (get_jenv_res == JNI_EDETACHED) {
6066                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6067         }
6068         return ret_ref;
6069 }
6070 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6071         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6072         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6073 }
6074 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6075         jclass c = (*env)->GetObjectClass(env, o);
6076         CHECK(c != NULL);
6077         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6078         atomic_init(&calls->refcnt, 1);
6079         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6080         calls->o = (*env)->NewWeakGlobalRef(env, o);
6081         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6082         CHECK(calls->get_node_secret_meth != NULL);
6083         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6084         CHECK(calls->get_destination_script_meth != NULL);
6085         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6086         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6087         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6088         CHECK(calls->get_channel_signer_meth != NULL);
6089         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6090         CHECK(calls->get_secure_random_bytes_meth != NULL);
6091         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6092         CHECK(calls->read_chan_signer_meth != NULL);
6093         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6094         CHECK(calls->sign_invoice_meth != NULL);
6095         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6096         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6097
6098         LDKKeysInterface ret = {
6099                 .this_arg = (void*) calls,
6100                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6101                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6102                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6103                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6104                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6105                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6106                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6107                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6108                 .free = LDKKeysInterface_JCalls_free,
6109         };
6110         return ret;
6111 }
6112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6113         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6114         *res_ptr = LDKKeysInterface_init(env, clz, o);
6115         return (uint64_t)res_ptr;
6116 }
6117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6118         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6120         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6121         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6122         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6123         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6124         return (int64_t)ret_conv;
6125 }
6126
6127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6128         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6129         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6130         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6131         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6132         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6133         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6134         CVec_u8Z_free(ret_var);
6135         return ret_arr;
6136 }
6137
6138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6139         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6140         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6141         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6142         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6143         int64_t ret_ref = 0;
6144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6147         ret_ref = (uintptr_t)ret_var.inner;
6148         if (ret_var.is_owned) {
6149                 ret_ref |= 1;
6150         }
6151         return ret_ref;
6152 }
6153
6154 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) {
6155         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6156         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6157         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6158         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6159         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6160         return (int64_t)ret_ret;
6161 }
6162
6163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6164         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6165         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6166         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6169         return ret_arr;
6170 }
6171
6172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6173         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6174         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6175         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6176         LDKu8slice reader_ref;
6177         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6178         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6179         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6180         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6181         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6182         return (int64_t)ret_conv;
6183 }
6184
6185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray hrp_bytes, jobjectArray invoice_data, jclass receipient) {
6186         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6187         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6188         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6189         LDKu8slice hrp_bytes_ref;
6190         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6191         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6192         LDKCVec_u5Z invoice_data_constr;
6193         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6194         if (invoice_data_constr.datalen > 0)
6195                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6196         else
6197                 invoice_data_constr.data = NULL;
6198         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6199         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6200                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6201                 
6202                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6203         }
6204         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6205         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6206         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6207         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6208         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6209         return (int64_t)ret_conv;
6210 }
6211
6212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6213         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6214         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6215         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6216         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6217         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6218         return ret_arr;
6219 }
6220
6221 typedef struct LDKFeeEstimator_JCalls {
6222         atomic_size_t refcnt;
6223         JavaVM *vm;
6224         jweak o;
6225         jmethodID get_est_sat_per_1000_weight_meth;
6226 } LDKFeeEstimator_JCalls;
6227 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6228         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6229         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6230                 JNIEnv *env;
6231                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6232                 if (get_jenv_res == JNI_EDETACHED) {
6233                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6234                 } else {
6235                         DO_ASSERT(get_jenv_res == JNI_OK);
6236                 }
6237                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6238                 if (get_jenv_res == JNI_EDETACHED) {
6239                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6240                 }
6241                 FREE(j_calls);
6242         }
6243 }
6244 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6245         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6246         JNIEnv *env;
6247         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6248         if (get_jenv_res == JNI_EDETACHED) {
6249                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6250         } else {
6251                 DO_ASSERT(get_jenv_res == JNI_OK);
6252         }
6253         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6254         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6255         CHECK(obj != NULL);
6256         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6257         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6258                 (*env)->ExceptionDescribe(env);
6259                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6260         }
6261         if (get_jenv_res == JNI_EDETACHED) {
6262                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6263         }
6264         return ret;
6265 }
6266 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6267         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6268         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6269 }
6270 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6271         jclass c = (*env)->GetObjectClass(env, o);
6272         CHECK(c != NULL);
6273         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6274         atomic_init(&calls->refcnt, 1);
6275         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6276         calls->o = (*env)->NewWeakGlobalRef(env, o);
6277         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6278         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6279
6280         LDKFeeEstimator ret = {
6281                 .this_arg = (void*) calls,
6282                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6283                 .free = LDKFeeEstimator_JCalls_free,
6284         };
6285         return ret;
6286 }
6287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6288         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6289         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6290         return (uint64_t)res_ptr;
6291 }
6292 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) {
6293         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6294         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6295         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6296         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6297         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6298         return ret_conv;
6299 }
6300
6301 typedef struct LDKLogger_JCalls {
6302         atomic_size_t refcnt;
6303         JavaVM *vm;
6304         jweak o;
6305         jmethodID log_meth;
6306 } LDKLogger_JCalls;
6307 static void LDKLogger_JCalls_free(void* this_arg) {
6308         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6309         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6310                 JNIEnv *env;
6311                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6312                 if (get_jenv_res == JNI_EDETACHED) {
6313                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6314                 } else {
6315                         DO_ASSERT(get_jenv_res == JNI_OK);
6316                 }
6317                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6318                 if (get_jenv_res == JNI_EDETACHED) {
6319                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6320                 }
6321                 FREE(j_calls);
6322         }
6323 }
6324 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6325         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6326         JNIEnv *env;
6327         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6328         if (get_jenv_res == JNI_EDETACHED) {
6329                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6330         } else {
6331                 DO_ASSERT(get_jenv_res == JNI_OK);
6332         }
6333         LDKRecord record_var = *record;
6334         int64_t record_ref = 0;
6335         record_var = Record_clone(&record_var);
6336         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6337         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6338         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6339         record_ref = (uintptr_t)record_var.inner;
6340         if (record_var.is_owned) {
6341                 record_ref |= 1;
6342         }
6343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6344         CHECK(obj != NULL);
6345         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
6346         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6347                 (*env)->ExceptionDescribe(env);
6348                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
6349         }
6350         if (get_jenv_res == JNI_EDETACHED) {
6351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6352         }
6353 }
6354 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6355         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6356         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6357 }
6358 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
6359         jclass c = (*env)->GetObjectClass(env, o);
6360         CHECK(c != NULL);
6361         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6362         atomic_init(&calls->refcnt, 1);
6363         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6364         calls->o = (*env)->NewWeakGlobalRef(env, o);
6365         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
6366         CHECK(calls->log_meth != NULL);
6367
6368         LDKLogger ret = {
6369                 .this_arg = (void*) calls,
6370                 .log = log_LDKLogger_jcall,
6371                 .free = LDKLogger_JCalls_free,
6372         };
6373         return ret;
6374 }
6375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
6376         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6377         *res_ptr = LDKLogger_init(env, clz, o);
6378         return (uint64_t)res_ptr;
6379 }
6380 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6381         return ThirtyTwoBytes_clone(&owner->a);
6382 }
6383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6384         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6385         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6386         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6387         return ret_arr;
6388 }
6389
6390 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6391         return &owner->b;
6392 }
6393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6394         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6395         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6396         int64_t ret_ref = 0;
6397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6400         ret_ref = (uintptr_t)ret_var.inner & ~1;
6401         return ret_ref;
6402 }
6403
6404 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6405 CHECK(owner->result_ok);
6406         return &*owner->contents.result;
6407 }
6408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6409         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6410         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6411         return ret_ret;
6412 }
6413
6414 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6415 CHECK(!owner->result_ok);
6416         return DecodeError_clone(&*owner->contents.err);
6417 }
6418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6419         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6420         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6421         int64_t ret_ref = 0;
6422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6425         ret_ref = (uintptr_t)ret_var.inner;
6426         if (ret_var.is_owned) {
6427                 ret_ref |= 1;
6428         }
6429         return ret_ref;
6430 }
6431
6432 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6433 CHECK(owner->result_ok);
6434         return ChannelConfig_clone(&*owner->contents.result);
6435 }
6436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6437         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6438         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6439         int64_t ret_ref = 0;
6440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6443         ret_ref = (uintptr_t)ret_var.inner;
6444         if (ret_var.is_owned) {
6445                 ret_ref |= 1;
6446         }
6447         return ret_ref;
6448 }
6449
6450 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6451 CHECK(!owner->result_ok);
6452         return DecodeError_clone(&*owner->contents.err);
6453 }
6454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6455         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6456         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6457         int64_t ret_ref = 0;
6458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6461         ret_ref = (uintptr_t)ret_var.inner;
6462         if (ret_var.is_owned) {
6463                 ret_ref |= 1;
6464         }
6465         return ret_ref;
6466 }
6467
6468 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6469 CHECK(owner->result_ok);
6470         return OutPoint_clone(&*owner->contents.result);
6471 }
6472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6473         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6474         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
6475         int64_t ret_ref = 0;
6476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6479         ret_ref = (uintptr_t)ret_var.inner;
6480         if (ret_var.is_owned) {
6481                 ret_ref |= 1;
6482         }
6483         return ret_ref;
6484 }
6485
6486 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6487 CHECK(!owner->result_ok);
6488         return DecodeError_clone(&*owner->contents.err);
6489 }
6490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6491         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6492         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
6493         int64_t ret_ref = 0;
6494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6497         ret_ref = (uintptr_t)ret_var.inner;
6498         if (ret_var.is_owned) {
6499                 ret_ref |= 1;
6500         }
6501         return ret_ref;
6502 }
6503
6504 typedef struct LDKType_JCalls {
6505         atomic_size_t refcnt;
6506         JavaVM *vm;
6507         jweak o;
6508         jmethodID type_id_meth;
6509         jmethodID debug_str_meth;
6510         jmethodID write_meth;
6511 } LDKType_JCalls;
6512 static void LDKType_JCalls_free(void* this_arg) {
6513         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6514         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6515                 JNIEnv *env;
6516                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6517                 if (get_jenv_res == JNI_EDETACHED) {
6518                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6519                 } else {
6520                         DO_ASSERT(get_jenv_res == JNI_OK);
6521                 }
6522                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6523                 if (get_jenv_res == JNI_EDETACHED) {
6524                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6525                 }
6526                 FREE(j_calls);
6527         }
6528 }
6529 uint16_t type_id_LDKType_jcall(const void* this_arg) {
6530         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6531         JNIEnv *env;
6532         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6533         if (get_jenv_res == JNI_EDETACHED) {
6534                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6535         } else {
6536                 DO_ASSERT(get_jenv_res == JNI_OK);
6537         }
6538         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6539         CHECK(obj != NULL);
6540         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
6541         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6542                 (*env)->ExceptionDescribe(env);
6543                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
6544         }
6545         if (get_jenv_res == JNI_EDETACHED) {
6546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6547         }
6548         return ret;
6549 }
6550 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
6551         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6552         JNIEnv *env;
6553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6554         if (get_jenv_res == JNI_EDETACHED) {
6555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6556         } else {
6557                 DO_ASSERT(get_jenv_res == JNI_OK);
6558         }
6559         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6560         CHECK(obj != NULL);
6561         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
6562         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6563                 (*env)->ExceptionDescribe(env);
6564                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
6565         }
6566         LDKStr ret_conv = java_to_owned_str(env, ret);
6567         if (get_jenv_res == JNI_EDETACHED) {
6568                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6569         }
6570         return ret_conv;
6571 }
6572 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
6573         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6574         JNIEnv *env;
6575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6576         if (get_jenv_res == JNI_EDETACHED) {
6577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6578         } else {
6579                 DO_ASSERT(get_jenv_res == JNI_OK);
6580         }
6581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6582         CHECK(obj != NULL);
6583         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6584         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6585                 (*env)->ExceptionDescribe(env);
6586                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
6587         }
6588         LDKCVec_u8Z ret_ref;
6589         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6590         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6591         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6592         if (get_jenv_res == JNI_EDETACHED) {
6593                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6594         }
6595         return ret_ref;
6596 }
6597 static void LDKType_JCalls_cloned(LDKType* new_obj) {
6598         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6599         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6600 }
6601 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6602         jclass c = (*env)->GetObjectClass(env, o);
6603         CHECK(c != NULL);
6604         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6605         atomic_init(&calls->refcnt, 1);
6606         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6607         calls->o = (*env)->NewWeakGlobalRef(env, o);
6608         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6609         CHECK(calls->type_id_meth != NULL);
6610         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6611         CHECK(calls->debug_str_meth != NULL);
6612         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6613         CHECK(calls->write_meth != NULL);
6614
6615         LDKType ret = {
6616                 .this_arg = (void*) calls,
6617                 .type_id = type_id_LDKType_jcall,
6618                 .debug_str = debug_str_LDKType_jcall,
6619                 .write = write_LDKType_jcall,
6620                 .cloned = LDKType_JCalls_cloned,
6621                 .free = LDKType_JCalls_free,
6622         };
6623         return ret;
6624 }
6625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6626         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6627         *res_ptr = LDKType_init(env, clz, o);
6628         return (uint64_t)res_ptr;
6629 }
6630 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6631         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6632         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6633         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6634         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6635         return ret_conv;
6636 }
6637
6638 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6639         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6640         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6641         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6642         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6643         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6644         Str_free(ret_str);
6645         return ret_conv;
6646 }
6647
6648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6649         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6650         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6651         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6652         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6653         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6654         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6655         CVec_u8Z_free(ret_var);
6656         return ret_arr;
6657 }
6658
6659 static jclass LDKCOption_TypeZ_Some_class = NULL;
6660 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6661 static jclass LDKCOption_TypeZ_None_class = NULL;
6662 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6664         LDKCOption_TypeZ_Some_class =
6665                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6666         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6667         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6668         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6669         LDKCOption_TypeZ_None_class =
6670                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6671         CHECK(LDKCOption_TypeZ_None_class != NULL);
6672         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6673         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6674 }
6675 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6676         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
6677         switch(obj->tag) {
6678                 case LDKCOption_TypeZ_Some: {
6679                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6680                         *some_ret = Type_clone(&obj->some);
6681                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
6682                 }
6683                 case LDKCOption_TypeZ_None: {
6684                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6685                 }
6686                 default: abort();
6687         }
6688 }
6689 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6690 CHECK(owner->result_ok);
6691         return COption_TypeZ_clone(&*owner->contents.result);
6692 }
6693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6694         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6695         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6696         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
6697         int64_t ret_ref = (uintptr_t)ret_copy;
6698         return ret_ref;
6699 }
6700
6701 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6702 CHECK(!owner->result_ok);
6703         return DecodeError_clone(&*owner->contents.err);
6704 }
6705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6706         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6707         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6708         int64_t ret_ref = 0;
6709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6712         ret_ref = (uintptr_t)ret_var.inner;
6713         if (ret_var.is_owned) {
6714                 ret_ref |= 1;
6715         }
6716         return ret_ref;
6717 }
6718
6719 static jclass LDKPaymentError_Invoice_class = NULL;
6720 static jmethodID LDKPaymentError_Invoice_meth = NULL;
6721 static jclass LDKPaymentError_Routing_class = NULL;
6722 static jmethodID LDKPaymentError_Routing_meth = NULL;
6723 static jclass LDKPaymentError_Sending_class = NULL;
6724 static jmethodID LDKPaymentError_Sending_meth = NULL;
6725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
6726         LDKPaymentError_Invoice_class =
6727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
6728         CHECK(LDKPaymentError_Invoice_class != NULL);
6729         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
6730         CHECK(LDKPaymentError_Invoice_meth != NULL);
6731         LDKPaymentError_Routing_class =
6732                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
6733         CHECK(LDKPaymentError_Routing_class != NULL);
6734         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
6735         CHECK(LDKPaymentError_Routing_meth != NULL);
6736         LDKPaymentError_Sending_class =
6737                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
6738         CHECK(LDKPaymentError_Sending_class != NULL);
6739         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
6740         CHECK(LDKPaymentError_Sending_meth != NULL);
6741 }
6742 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6743         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6744         switch(obj->tag) {
6745                 case LDKPaymentError_Invoice: {
6746                         LDKStr invoice_str = obj->invoice;
6747                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
6748                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
6749                 }
6750                 case LDKPaymentError_Routing: {
6751                         LDKLightningError routing_var = obj->routing;
6752                         int64_t routing_ref = 0;
6753                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6754                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6755                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6756                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6757                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
6758                 }
6759                 case LDKPaymentError_Sending: {
6760                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6761                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
6762                 }
6763                 default: abort();
6764         }
6765 }
6766 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6767 CHECK(owner->result_ok);
6768         return ThirtyTwoBytes_clone(&*owner->contents.result);
6769 }
6770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6771         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6772         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6773         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
6774         return ret_arr;
6775 }
6776
6777 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6778 CHECK(!owner->result_ok);
6779         return PaymentError_clone(&*owner->contents.err);
6780 }
6781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6782         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6783         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6784         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6785         int64_t ret_ref = (uintptr_t)ret_copy;
6786         return ret_ref;
6787 }
6788
6789 static jclass LDKParseError_Bech32Error_class = NULL;
6790 static jmethodID LDKParseError_Bech32Error_meth = NULL;
6791 static jclass LDKParseError_ParseAmountError_class = NULL;
6792 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
6793 static jclass LDKParseError_MalformedSignature_class = NULL;
6794 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
6795 static jclass LDKParseError_BadPrefix_class = NULL;
6796 static jmethodID LDKParseError_BadPrefix_meth = NULL;
6797 static jclass LDKParseError_UnknownCurrency_class = NULL;
6798 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
6799 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
6800 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
6801 static jclass LDKParseError_MalformedHRP_class = NULL;
6802 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
6803 static jclass LDKParseError_TooShortDataPart_class = NULL;
6804 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
6805 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
6806 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
6807 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
6808 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
6809 static jclass LDKParseError_PaddingError_class = NULL;
6810 static jmethodID LDKParseError_PaddingError_meth = NULL;
6811 static jclass LDKParseError_IntegerOverflowError_class = NULL;
6812 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
6813 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
6814 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
6815 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
6816 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
6817 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
6818 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
6819 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
6820 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
6821 static jclass LDKParseError_InvalidSliceLength_class = NULL;
6822 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
6823 static jclass LDKParseError_Skip_class = NULL;
6824 static jmethodID LDKParseError_Skip_meth = NULL;
6825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
6826         LDKParseError_Bech32Error_class =
6827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
6828         CHECK(LDKParseError_Bech32Error_class != NULL);
6829         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
6830         CHECK(LDKParseError_Bech32Error_meth != NULL);
6831         LDKParseError_ParseAmountError_class =
6832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
6833         CHECK(LDKParseError_ParseAmountError_class != NULL);
6834         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
6835         CHECK(LDKParseError_ParseAmountError_meth != NULL);
6836         LDKParseError_MalformedSignature_class =
6837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
6838         CHECK(LDKParseError_MalformedSignature_class != NULL);
6839         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
6840         CHECK(LDKParseError_MalformedSignature_meth != NULL);
6841         LDKParseError_BadPrefix_class =
6842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
6843         CHECK(LDKParseError_BadPrefix_class != NULL);
6844         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
6845         CHECK(LDKParseError_BadPrefix_meth != NULL);
6846         LDKParseError_UnknownCurrency_class =
6847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
6848         CHECK(LDKParseError_UnknownCurrency_class != NULL);
6849         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
6850         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
6851         LDKParseError_UnknownSiPrefix_class =
6852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
6853         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
6854         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
6855         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
6856         LDKParseError_MalformedHRP_class =
6857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
6858         CHECK(LDKParseError_MalformedHRP_class != NULL);
6859         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
6860         CHECK(LDKParseError_MalformedHRP_meth != NULL);
6861         LDKParseError_TooShortDataPart_class =
6862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
6863         CHECK(LDKParseError_TooShortDataPart_class != NULL);
6864         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
6865         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
6866         LDKParseError_UnexpectedEndOfTaggedFields_class =
6867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
6868         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
6869         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
6870         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
6871         LDKParseError_DescriptionDecodeError_class =
6872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
6873         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
6874         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
6875         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
6876         LDKParseError_PaddingError_class =
6877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
6878         CHECK(LDKParseError_PaddingError_class != NULL);
6879         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
6880         CHECK(LDKParseError_PaddingError_meth != NULL);
6881         LDKParseError_IntegerOverflowError_class =
6882                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
6883         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
6884         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
6885         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
6886         LDKParseError_InvalidSegWitProgramLength_class =
6887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
6888         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
6889         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
6890         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
6891         LDKParseError_InvalidPubKeyHashLength_class =
6892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
6893         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
6894         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
6895         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
6896         LDKParseError_InvalidScriptHashLength_class =
6897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
6898         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
6899         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
6900         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
6901         LDKParseError_InvalidRecoveryId_class =
6902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
6903         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
6904         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
6905         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
6906         LDKParseError_InvalidSliceLength_class =
6907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
6908         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
6909         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
6910         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
6911         LDKParseError_Skip_class =
6912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
6913         CHECK(LDKParseError_Skip_class != NULL);
6914         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
6915         CHECK(LDKParseError_Skip_meth != NULL);
6916 }
6917 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6918         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6919         switch(obj->tag) {
6920                 case LDKParseError_Bech32Error: {
6921                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
6922                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
6923                 }
6924                 case LDKParseError_ParseAmountError: {
6925                         /*obj->parse_amount_error*/
6926                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
6927                 }
6928                 case LDKParseError_MalformedSignature: {
6929                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
6930                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
6931                 }
6932                 case LDKParseError_BadPrefix: {
6933                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
6934                 }
6935                 case LDKParseError_UnknownCurrency: {
6936                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
6937                 }
6938                 case LDKParseError_UnknownSiPrefix: {
6939                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
6940                 }
6941                 case LDKParseError_MalformedHRP: {
6942                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
6943                 }
6944                 case LDKParseError_TooShortDataPart: {
6945                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
6946                 }
6947                 case LDKParseError_UnexpectedEndOfTaggedFields: {
6948                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
6949                 }
6950                 case LDKParseError_DescriptionDecodeError: {
6951                         /*obj->description_decode_error*/
6952                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
6953                 }
6954                 case LDKParseError_PaddingError: {
6955                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
6956                 }
6957                 case LDKParseError_IntegerOverflowError: {
6958                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
6959                 }
6960                 case LDKParseError_InvalidSegWitProgramLength: {
6961                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
6962                 }
6963                 case LDKParseError_InvalidPubKeyHashLength: {
6964                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
6965                 }
6966                 case LDKParseError_InvalidScriptHashLength: {
6967                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
6968                 }
6969                 case LDKParseError_InvalidRecoveryId: {
6970                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
6971                 }
6972                 case LDKParseError_InvalidSliceLength: {
6973                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
6974                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
6975                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
6976                 }
6977                 case LDKParseError_Skip: {
6978                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
6979                 }
6980                 default: abort();
6981         }
6982 }
6983 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6984 CHECK(owner->result_ok);
6985         return SiPrefix_clone(&*owner->contents.result);
6986 }
6987 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6988         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6989         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
6990         return ret_conv;
6991 }
6992
6993 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6994 CHECK(!owner->result_ok);
6995         return ParseError_clone(&*owner->contents.err);
6996 }
6997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6998         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6999         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7000         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7001         int64_t ret_ref = (uintptr_t)ret_copy;
7002         return ret_ref;
7003 }
7004
7005 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7006 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7007 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7008 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7010         LDKParseOrSemanticError_ParseError_class =
7011                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7012         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7013         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7014         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7015         LDKParseOrSemanticError_SemanticError_class =
7016                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7017         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7018         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7019         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7020 }
7021 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7022         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7023         switch(obj->tag) {
7024                 case LDKParseOrSemanticError_ParseError: {
7025                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7026                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7027                 }
7028                 case LDKParseOrSemanticError_SemanticError: {
7029                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7030                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7031                 }
7032                 default: abort();
7033         }
7034 }
7035 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7036 CHECK(owner->result_ok);
7037         return Invoice_clone(&*owner->contents.result);
7038 }
7039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7040         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7041         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7042         int64_t ret_ref = 0;
7043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7046         ret_ref = (uintptr_t)ret_var.inner;
7047         if (ret_var.is_owned) {
7048                 ret_ref |= 1;
7049         }
7050         return ret_ref;
7051 }
7052
7053 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7054 CHECK(!owner->result_ok);
7055         return ParseOrSemanticError_clone(&*owner->contents.err);
7056 }
7057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7058         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7059         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7060         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7061         int64_t ret_ref = (uintptr_t)ret_copy;
7062         return ret_ref;
7063 }
7064
7065 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7066 CHECK(owner->result_ok);
7067         return SignedRawInvoice_clone(&*owner->contents.result);
7068 }
7069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7070         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7071         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7072         int64_t ret_ref = 0;
7073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7076         ret_ref = (uintptr_t)ret_var.inner;
7077         if (ret_var.is_owned) {
7078                 ret_ref |= 1;
7079         }
7080         return ret_ref;
7081 }
7082
7083 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7084 CHECK(!owner->result_ok);
7085         return ParseError_clone(&*owner->contents.err);
7086 }
7087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7088         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7089         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7090         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7091         int64_t ret_ref = (uintptr_t)ret_copy;
7092         return ret_ref;
7093 }
7094
7095 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7096         return RawInvoice_clone(&owner->a);
7097 }
7098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7099         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7100         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7101         int64_t ret_ref = 0;
7102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7105         ret_ref = (uintptr_t)ret_var.inner;
7106         if (ret_var.is_owned) {
7107                 ret_ref |= 1;
7108         }
7109         return ret_ref;
7110 }
7111
7112 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7113         return ThirtyTwoBytes_clone(&owner->b);
7114 }
7115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7116         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7117         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7118         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7119         return ret_arr;
7120 }
7121
7122 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7123         return InvoiceSignature_clone(&owner->c);
7124 }
7125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7126         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7127         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7128         int64_t ret_ref = 0;
7129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7132         ret_ref = (uintptr_t)ret_var.inner;
7133         if (ret_var.is_owned) {
7134                 ret_ref |= 1;
7135         }
7136         return ret_ref;
7137 }
7138
7139 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7140 CHECK(owner->result_ok);
7141         return PayeePubKey_clone(&*owner->contents.result);
7142 }
7143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7144         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7145         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7146         int64_t ret_ref = 0;
7147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7150         ret_ref = (uintptr_t)ret_var.inner;
7151         if (ret_var.is_owned) {
7152                 ret_ref |= 1;
7153         }
7154         return ret_ref;
7155 }
7156
7157 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7158 CHECK(!owner->result_ok);
7159         return *owner->contents.err;
7160 }
7161 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7162         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7163         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7164         return ret_conv;
7165 }
7166
7167 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7168         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7169         for (size_t i = 0; i < ret.datalen; i++) {
7170                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7171         }
7172         return ret;
7173 }
7174 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7175 CHECK(owner->result_ok);
7176         return PositiveTimestamp_clone(&*owner->contents.result);
7177 }
7178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7179         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7180         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7181         int64_t ret_ref = 0;
7182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7185         ret_ref = (uintptr_t)ret_var.inner;
7186         if (ret_var.is_owned) {
7187                 ret_ref |= 1;
7188         }
7189         return ret_ref;
7190 }
7191
7192 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7193 CHECK(!owner->result_ok);
7194         return CreationError_clone(&*owner->contents.err);
7195 }
7196 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7197         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7198         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7199         return ret_conv;
7200 }
7201
7202 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7203 CHECK(owner->result_ok);
7204         return *owner->contents.result;
7205 }
7206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7207         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7208         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7209 }
7210
7211 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7212 CHECK(!owner->result_ok);
7213         return SemanticError_clone(&*owner->contents.err);
7214 }
7215 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7216         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7217         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7218         return ret_conv;
7219 }
7220
7221 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7222 CHECK(owner->result_ok);
7223         return Invoice_clone(&*owner->contents.result);
7224 }
7225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7226         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7227         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7228         int64_t ret_ref = 0;
7229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7232         ret_ref = (uintptr_t)ret_var.inner;
7233         if (ret_var.is_owned) {
7234                 ret_ref |= 1;
7235         }
7236         return ret_ref;
7237 }
7238
7239 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7240 CHECK(!owner->result_ok);
7241         return SemanticError_clone(&*owner->contents.err);
7242 }
7243 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7244         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7245         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7246         return ret_conv;
7247 }
7248
7249 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7250 CHECK(owner->result_ok);
7251         return Description_clone(&*owner->contents.result);
7252 }
7253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7254         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7255         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7256         int64_t ret_ref = 0;
7257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7260         ret_ref = (uintptr_t)ret_var.inner;
7261         if (ret_var.is_owned) {
7262                 ret_ref |= 1;
7263         }
7264         return ret_ref;
7265 }
7266
7267 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7268 CHECK(!owner->result_ok);
7269         return CreationError_clone(&*owner->contents.err);
7270 }
7271 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7272         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7273         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7274         return ret_conv;
7275 }
7276
7277 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7278 CHECK(owner->result_ok);
7279         return PrivateRoute_clone(&*owner->contents.result);
7280 }
7281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7282         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7283         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7284         int64_t ret_ref = 0;
7285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7288         ret_ref = (uintptr_t)ret_var.inner;
7289         if (ret_var.is_owned) {
7290                 ret_ref |= 1;
7291         }
7292         return ret_ref;
7293 }
7294
7295 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7296 CHECK(!owner->result_ok);
7297         return CreationError_clone(&*owner->contents.err);
7298 }
7299 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7300         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7301         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
7302         return ret_conv;
7303 }
7304
7305 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7306 CHECK(owner->result_ok);
7307         return *owner->contents.result;
7308 }
7309 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7310         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7311         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
7312         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7313         return ret_conv;
7314 }
7315
7316 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7317 CHECK(!owner->result_ok);
7318         return *owner->contents.err;
7319 }
7320 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7321         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7322         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
7323         return ret_conv;
7324 }
7325
7326 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7327 CHECK(owner->result_ok);
7328         return ChannelMonitorUpdate_clone(&*owner->contents.result);
7329 }
7330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7331         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7332         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
7333         int64_t ret_ref = 0;
7334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7337         ret_ref = (uintptr_t)ret_var.inner;
7338         if (ret_var.is_owned) {
7339                 ret_ref |= 1;
7340         }
7341         return ret_ref;
7342 }
7343
7344 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7345 CHECK(!owner->result_ok);
7346         return DecodeError_clone(&*owner->contents.err);
7347 }
7348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7349         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7350         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
7351         int64_t ret_ref = 0;
7352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7355         ret_ref = (uintptr_t)ret_var.inner;
7356         if (ret_var.is_owned) {
7357                 ret_ref |= 1;
7358         }
7359         return ret_ref;
7360 }
7361
7362 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
7363 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
7364 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
7365 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
7366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
7367         LDKCOption_MonitorEventZ_Some_class =
7368                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7369         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7370         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7371         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7372         LDKCOption_MonitorEventZ_None_class =
7373                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7374         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7375         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7376         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7377 }
7378 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7379         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
7380         switch(obj->tag) {
7381                 case LDKCOption_MonitorEventZ_Some: {
7382                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7383                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7384                 }
7385                 case LDKCOption_MonitorEventZ_None: {
7386                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7387                 }
7388                 default: abort();
7389         }
7390 }
7391 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7392 CHECK(owner->result_ok);
7393         return COption_MonitorEventZ_clone(&*owner->contents.result);
7394 }
7395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7396         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7397         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7398         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7399         int64_t ret_ref = (uintptr_t)ret_copy;
7400         return ret_ref;
7401 }
7402
7403 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7404 CHECK(!owner->result_ok);
7405         return DecodeError_clone(&*owner->contents.err);
7406 }
7407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7408         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7409         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7410         int64_t ret_ref = 0;
7411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7414         ret_ref = (uintptr_t)ret_var.inner;
7415         if (ret_var.is_owned) {
7416                 ret_ref |= 1;
7417         }
7418         return ret_ref;
7419 }
7420
7421 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7422 CHECK(owner->result_ok);
7423         return HTLCUpdate_clone(&*owner->contents.result);
7424 }
7425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7426         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7427         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7428         int64_t ret_ref = 0;
7429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7432         ret_ref = (uintptr_t)ret_var.inner;
7433         if (ret_var.is_owned) {
7434                 ret_ref |= 1;
7435         }
7436         return ret_ref;
7437 }
7438
7439 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7440 CHECK(!owner->result_ok);
7441         return DecodeError_clone(&*owner->contents.err);
7442 }
7443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7444         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7445         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7446         int64_t ret_ref = 0;
7447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7450         ret_ref = (uintptr_t)ret_var.inner;
7451         if (ret_var.is_owned) {
7452                 ret_ref |= 1;
7453         }
7454         return ret_ref;
7455 }
7456
7457 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7458         return OutPoint_clone(&owner->a);
7459 }
7460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7461         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7462         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
7463         int64_t ret_ref = 0;
7464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7467         ret_ref = (uintptr_t)ret_var.inner;
7468         if (ret_var.is_owned) {
7469                 ret_ref |= 1;
7470         }
7471         return ret_ref;
7472 }
7473
7474 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7475         return CVec_u8Z_clone(&owner->b);
7476 }
7477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7478         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7479         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
7480         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7481         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7482         CVec_u8Z_free(ret_var);
7483         return ret_arr;
7484 }
7485
7486 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7487         return owner->a;
7488 }
7489 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7490         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7491         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
7492         return ret_conv;
7493 }
7494
7495 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7496         return CVec_u8Z_clone(&owner->b);
7497 }
7498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7499         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7500         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
7501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7503         CVec_u8Z_free(ret_var);
7504         return ret_arr;
7505 }
7506
7507 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
7508         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
7509         for (size_t i = 0; i < ret.datalen; i++) {
7510                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
7511         }
7512         return ret;
7513 }
7514 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7515         return ThirtyTwoBytes_clone(&owner->a);
7516 }
7517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7518         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7519         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
7521         return ret_arr;
7522 }
7523
7524 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7525         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
7526 }
7527 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7528         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7529         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
7530         int64_tArray ret_arr = NULL;
7531         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7532         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7533         for (size_t v = 0; v < ret_var.datalen; v++) {
7534                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7535                 *ret_conv_21_conv = ret_var.data[v];
7536                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
7537         }
7538         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7539         FREE(ret_var.data);
7540         return ret_arr;
7541 }
7542
7543 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
7544         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 };
7545         for (size_t i = 0; i < ret.datalen; i++) {
7546                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
7547         }
7548         return ret;
7549 }
7550 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
7551         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
7552         for (size_t i = 0; i < ret.datalen; i++) {
7553                 ret.data[i] = Event_clone(&orig->data[i]);
7554         }
7555         return ret;
7556 }
7557 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7558         return owner->a;
7559 }
7560 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7561         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7562         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
7563         return ret_conv;
7564 }
7565
7566 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7567         return TxOut_clone(&owner->b);
7568 }
7569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7570         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7571         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7572         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7573         return (int64_t)ret_ref;
7574 }
7575
7576 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7577         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7578         for (size_t i = 0; i < ret.datalen; i++) {
7579                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7580         }
7581         return ret;
7582 }
7583 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7584         return ThirtyTwoBytes_clone(&owner->a);
7585 }
7586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7587         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7588         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
7590         return ret_arr;
7591 }
7592
7593 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7594         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7595 }
7596 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7597         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7598         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7599         int64_tArray ret_arr = NULL;
7600         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7601         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7602         for (size_t u = 0; u < ret_var.datalen; u++) {
7603                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7604                 *ret_conv_20_conv = ret_var.data[u];
7605                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
7606         }
7607         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7608         FREE(ret_var.data);
7609         return ret_arr;
7610 }
7611
7612 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
7613         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 };
7614         for (size_t i = 0; i < ret.datalen; i++) {
7615                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7616         }
7617         return ret;
7618 }
7619 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
7620 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
7621 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
7622 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
7623 static jclass LDKBalance_ContentiousClaimable_class = NULL;
7624 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
7625 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
7626 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
7627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
7628         LDKBalance_ClaimableOnChannelClose_class =
7629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
7630         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
7631         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
7632         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
7633         LDKBalance_ClaimableAwaitingConfirmations_class =
7634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
7635         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
7636         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
7637         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
7638         LDKBalance_ContentiousClaimable_class =
7639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
7640         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
7641         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
7642         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
7643         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
7644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
7645         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
7646         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
7647         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
7648 }
7649 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7650         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
7651         switch(obj->tag) {
7652                 case LDKBalance_ClaimableOnChannelClose: {
7653                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
7654                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
7655                 }
7656                 case LDKBalance_ClaimableAwaitingConfirmations: {
7657                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
7658                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
7659                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
7660                 }
7661                 case LDKBalance_ContentiousClaimable: {
7662                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
7663                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
7664                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
7665                 }
7666                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
7667                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
7668                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
7669                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
7670                 }
7671                 default: abort();
7672         }
7673 }
7674 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7675         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7676         for (size_t i = 0; i < ret.datalen; i++) {
7677                 ret.data[i] = Balance_clone(&orig->data[i]);
7678         }
7679         return ret;
7680 }
7681 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7682 CHECK(owner->result_ok);
7683         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
7684 }
7685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7686         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7687         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7688         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7689         return ((int64_t)ret_conv);
7690 }
7691
7692 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7693 CHECK(!owner->result_ok);
7694         return DecodeError_clone(&*owner->contents.err);
7695 }
7696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7697         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7698         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7699         int64_t ret_ref = 0;
7700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7703         ret_ref = (uintptr_t)ret_var.inner;
7704         if (ret_var.is_owned) {
7705                 ret_ref |= 1;
7706         }
7707         return ret_ref;
7708 }
7709
7710 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7711 CHECK(owner->result_ok);
7712         return *owner->contents.result;
7713 }
7714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7715         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7716         CResult_NoneLightningErrorZ_get_ok(owner_conv);
7717 }
7718
7719 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7720 CHECK(!owner->result_ok);
7721         return LightningError_clone(&*owner->contents.err);
7722 }
7723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7724         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7725         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
7726         int64_t ret_ref = 0;
7727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7730         ret_ref = (uintptr_t)ret_var.inner;
7731         if (ret_var.is_owned) {
7732                 ret_ref |= 1;
7733         }
7734         return ret_ref;
7735 }
7736
7737 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7738         return owner->a;
7739 }
7740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7741         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7742         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
7743         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
7744         return ret_arr;
7745 }
7746
7747 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7748         return Type_clone(&owner->b);
7749 }
7750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7751         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7752         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7753         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7754         return (int64_t)ret_ret;
7755 }
7756
7757 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7758         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7759         for (size_t i = 0; i < ret.datalen; i++) {
7760                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7761         }
7762         return ret;
7763 }
7764 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7765 CHECK(owner->result_ok);
7766         return *owner->contents.result;
7767 }
7768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7769         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7770         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
7771         return ret_conv;
7772 }
7773
7774 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7775 CHECK(!owner->result_ok);
7776         return LightningError_clone(&*owner->contents.err);
7777 }
7778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7779         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7780         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
7781         int64_t ret_ref = 0;
7782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7785         ret_ref = (uintptr_t)ret_var.inner;
7786         if (ret_var.is_owned) {
7787                 ret_ref |= 1;
7788         }
7789         return ret_ref;
7790 }
7791
7792 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7793         return ChannelAnnouncement_clone(&owner->a);
7794 }
7795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7796         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7797         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
7798         int64_t ret_ref = 0;
7799         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7800         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7802         ret_ref = (uintptr_t)ret_var.inner;
7803         if (ret_var.is_owned) {
7804                 ret_ref |= 1;
7805         }
7806         return ret_ref;
7807 }
7808
7809 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7810         return ChannelUpdate_clone(&owner->b);
7811 }
7812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7813         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7814         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
7815         int64_t ret_ref = 0;
7816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7819         ret_ref = (uintptr_t)ret_var.inner;
7820         if (ret_var.is_owned) {
7821                 ret_ref |= 1;
7822         }
7823         return ret_ref;
7824 }
7825
7826 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7827         return ChannelUpdate_clone(&owner->c);
7828 }
7829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7830         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7831         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
7832         int64_t ret_ref = 0;
7833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7836         ret_ref = (uintptr_t)ret_var.inner;
7837         if (ret_var.is_owned) {
7838                 ret_ref |= 1;
7839         }
7840         return ret_ref;
7841 }
7842
7843 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
7844         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
7845         for (size_t i = 0; i < ret.datalen; i++) {
7846                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
7847         }
7848         return ret;
7849 }
7850 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
7851         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
7852         for (size_t i = 0; i < ret.datalen; i++) {
7853                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
7854         }
7855         return ret;
7856 }
7857 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
7858 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
7859 static jclass LDKCOption_NetAddressZ_None_class = NULL;
7860 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
7861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
7862         LDKCOption_NetAddressZ_Some_class =
7863                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
7864         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
7865         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
7866         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
7867         LDKCOption_NetAddressZ_None_class =
7868                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
7869         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
7870         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
7871         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
7872 }
7873 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7874         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
7875         switch(obj->tag) {
7876                 case LDKCOption_NetAddressZ_Some: {
7877                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7878                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
7879                 }
7880                 case LDKCOption_NetAddressZ_None: {
7881                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
7882                 }
7883                 default: abort();
7884         }
7885 }
7886 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7887 CHECK(owner->result_ok);
7888         return CVec_u8Z_clone(&*owner->contents.result);
7889 }
7890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7891         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7892         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7895         CVec_u8Z_free(ret_var);
7896         return ret_arr;
7897 }
7898
7899 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7900 CHECK(!owner->result_ok);
7901         return PeerHandleError_clone(&*owner->contents.err);
7902 }
7903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7904         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7905         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7906         int64_t ret_ref = 0;
7907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7910         ret_ref = (uintptr_t)ret_var.inner;
7911         if (ret_var.is_owned) {
7912                 ret_ref |= 1;
7913         }
7914         return ret_ref;
7915 }
7916
7917 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7918 CHECK(owner->result_ok);
7919         return *owner->contents.result;
7920 }
7921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7922         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7923         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7924 }
7925
7926 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7927 CHECK(!owner->result_ok);
7928         return PeerHandleError_clone(&*owner->contents.err);
7929 }
7930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7931         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7932         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7933         int64_t ret_ref = 0;
7934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7937         ret_ref = (uintptr_t)ret_var.inner;
7938         if (ret_var.is_owned) {
7939                 ret_ref |= 1;
7940         }
7941         return ret_ref;
7942 }
7943
7944 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7945 CHECK(owner->result_ok);
7946         return *owner->contents.result;
7947 }
7948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7949         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7950         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7951         return ret_conv;
7952 }
7953
7954 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7955 CHECK(!owner->result_ok);
7956         return PeerHandleError_clone(&*owner->contents.err);
7957 }
7958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7959         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7960         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7961         int64_t ret_ref = 0;
7962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7965         ret_ref = (uintptr_t)ret_var.inner;
7966         if (ret_var.is_owned) {
7967                 ret_ref |= 1;
7968         }
7969         return ret_ref;
7970 }
7971
7972 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7973 CHECK(owner->result_ok);
7974         return NodeId_clone(&*owner->contents.result);
7975 }
7976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7977         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7978         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
7979         int64_t ret_ref = 0;
7980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7983         ret_ref = (uintptr_t)ret_var.inner;
7984         if (ret_var.is_owned) {
7985                 ret_ref |= 1;
7986         }
7987         return ret_ref;
7988 }
7989
7990 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7991 CHECK(!owner->result_ok);
7992         return DecodeError_clone(&*owner->contents.err);
7993 }
7994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7995         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7996         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
7997         int64_t ret_ref = 0;
7998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8001         ret_ref = (uintptr_t)ret_var.inner;
8002         if (ret_var.is_owned) {
8003                 ret_ref |= 1;
8004         }
8005         return ret_ref;
8006 }
8007
8008 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
8009 CHECK(owner->result_ok);
8010         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
8011 }
8012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8013         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
8014         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8015         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
8016         int64_t ret_ref = (uintptr_t)ret_copy;
8017         return ret_ref;
8018 }
8019
8020 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
8021 CHECK(!owner->result_ok);
8022         return DecodeError_clone(&*owner->contents.err);
8023 }
8024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8025         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
8026         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
8027         int64_t ret_ref = 0;
8028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8031         ret_ref = (uintptr_t)ret_var.inner;
8032         if (ret_var.is_owned) {
8033                 ret_ref |= 1;
8034         }
8035         return ret_ref;
8036 }
8037
8038 typedef struct LDKAccess_JCalls {
8039         atomic_size_t refcnt;
8040         JavaVM *vm;
8041         jweak o;
8042         jmethodID get_utxo_meth;
8043 } LDKAccess_JCalls;
8044 static void LDKAccess_JCalls_free(void* this_arg) {
8045         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
8046         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8047                 JNIEnv *env;
8048                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8049                 if (get_jenv_res == JNI_EDETACHED) {
8050                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8051                 } else {
8052                         DO_ASSERT(get_jenv_res == JNI_OK);
8053                 }
8054                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8055                 if (get_jenv_res == JNI_EDETACHED) {
8056                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8057                 }
8058                 FREE(j_calls);
8059         }
8060 }
8061 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
8062         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
8063         JNIEnv *env;
8064         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8065         if (get_jenv_res == JNI_EDETACHED) {
8066                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8067         } else {
8068                 DO_ASSERT(get_jenv_res == JNI_OK);
8069         }
8070         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
8071         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
8072         int64_t short_channel_id_conv = short_channel_id;
8073         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8074         CHECK(obj != NULL);
8075         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
8076         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8077                 (*env)->ExceptionDescribe(env);
8078                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
8079         }
8080         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8081         CHECK_ACCESS(ret_ptr);
8082         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
8083         FREE((void*)ret);
8084         if (get_jenv_res == JNI_EDETACHED) {
8085                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8086         }
8087         return ret_conv;
8088 }
8089 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
8090         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
8091         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8092 }
8093 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
8094         jclass c = (*env)->GetObjectClass(env, o);
8095         CHECK(c != NULL);
8096         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
8097         atomic_init(&calls->refcnt, 1);
8098         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8099         calls->o = (*env)->NewWeakGlobalRef(env, o);
8100         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
8101         CHECK(calls->get_utxo_meth != NULL);
8102
8103         LDKAccess ret = {
8104                 .this_arg = (void*) calls,
8105                 .get_utxo = get_utxo_LDKAccess_jcall,
8106                 .free = LDKAccess_JCalls_free,
8107         };
8108         return ret;
8109 }
8110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
8111         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
8112         *res_ptr = LDKAccess_init(env, clz, o);
8113         return (uint64_t)res_ptr;
8114 }
8115 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) {
8116         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8117         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8118         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
8119         unsigned char genesis_hash_arr[32];
8120         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
8121         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
8122         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
8123         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8124         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
8125         return (int64_t)ret_conv;
8126 }
8127
8128 static jclass LDKCOption_AccessZ_Some_class = NULL;
8129 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
8130 static jclass LDKCOption_AccessZ_None_class = NULL;
8131 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
8132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
8133         LDKCOption_AccessZ_Some_class =
8134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
8135         CHECK(LDKCOption_AccessZ_Some_class != NULL);
8136         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
8137         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
8138         LDKCOption_AccessZ_None_class =
8139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
8140         CHECK(LDKCOption_AccessZ_None_class != NULL);
8141         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
8142         CHECK(LDKCOption_AccessZ_None_meth != NULL);
8143 }
8144 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8145         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
8146         switch(obj->tag) {
8147                 case LDKCOption_AccessZ_Some: {
8148                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
8149                         *some_ret = obj->some;
8150                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8151                         if ((*some_ret).free == LDKAccess_JCalls_free) {
8152                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8153                                 LDKAccess_JCalls_cloned(&(*some_ret));
8154                         }
8155                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
8156                 }
8157                 case LDKCOption_AccessZ_None: {
8158                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
8159                 }
8160                 default: abort();
8161         }
8162 }
8163 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
8164 CHECK(owner->result_ok);
8165         return ChannelUpdateInfo_clone(&*owner->contents.result);
8166 }
8167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8168         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
8169         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
8170         int64_t ret_ref = 0;
8171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8174         ret_ref = (uintptr_t)ret_var.inner;
8175         if (ret_var.is_owned) {
8176                 ret_ref |= 1;
8177         }
8178         return ret_ref;
8179 }
8180
8181 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
8182 CHECK(!owner->result_ok);
8183         return DecodeError_clone(&*owner->contents.err);
8184 }
8185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8186         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
8187         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
8188         int64_t ret_ref = 0;
8189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8192         ret_ref = (uintptr_t)ret_var.inner;
8193         if (ret_var.is_owned) {
8194                 ret_ref |= 1;
8195         }
8196         return ret_ref;
8197 }
8198
8199 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
8200 CHECK(owner->result_ok);
8201         return ChannelInfo_clone(&*owner->contents.result);
8202 }
8203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8204         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
8205         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
8206         int64_t ret_ref = 0;
8207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8210         ret_ref = (uintptr_t)ret_var.inner;
8211         if (ret_var.is_owned) {
8212                 ret_ref |= 1;
8213         }
8214         return ret_ref;
8215 }
8216
8217 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
8218 CHECK(!owner->result_ok);
8219         return DecodeError_clone(&*owner->contents.err);
8220 }
8221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8222         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
8223         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
8224         int64_t ret_ref = 0;
8225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8228         ret_ref = (uintptr_t)ret_var.inner;
8229         if (ret_var.is_owned) {
8230                 ret_ref |= 1;
8231         }
8232         return ret_ref;
8233 }
8234
8235 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
8236 CHECK(owner->result_ok);
8237         return RoutingFees_clone(&*owner->contents.result);
8238 }
8239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8240         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
8241         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
8242         int64_t ret_ref = 0;
8243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8246         ret_ref = (uintptr_t)ret_var.inner;
8247         if (ret_var.is_owned) {
8248                 ret_ref |= 1;
8249         }
8250         return ret_ref;
8251 }
8252
8253 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
8254 CHECK(!owner->result_ok);
8255         return DecodeError_clone(&*owner->contents.err);
8256 }
8257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8258         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
8259         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
8260         int64_t ret_ref = 0;
8261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8264         ret_ref = (uintptr_t)ret_var.inner;
8265         if (ret_var.is_owned) {
8266                 ret_ref |= 1;
8267         }
8268         return ret_ref;
8269 }
8270
8271 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
8272 CHECK(owner->result_ok);
8273         return NodeAnnouncementInfo_clone(&*owner->contents.result);
8274 }
8275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8276         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
8277         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
8278         int64_t ret_ref = 0;
8279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8282         ret_ref = (uintptr_t)ret_var.inner;
8283         if (ret_var.is_owned) {
8284                 ret_ref |= 1;
8285         }
8286         return ret_ref;
8287 }
8288
8289 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
8290 CHECK(!owner->result_ok);
8291         return DecodeError_clone(&*owner->contents.err);
8292 }
8293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8294         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
8295         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
8296         int64_t ret_ref = 0;
8297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8300         ret_ref = (uintptr_t)ret_var.inner;
8301         if (ret_var.is_owned) {
8302                 ret_ref |= 1;
8303         }
8304         return ret_ref;
8305 }
8306
8307 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
8308         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
8309         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
8310         return ret;
8311 }
8312 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
8313 CHECK(owner->result_ok);
8314         return NodeInfo_clone(&*owner->contents.result);
8315 }
8316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8317         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
8318         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
8319         int64_t ret_ref = 0;
8320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8323         ret_ref = (uintptr_t)ret_var.inner;
8324         if (ret_var.is_owned) {
8325                 ret_ref |= 1;
8326         }
8327         return ret_ref;
8328 }
8329
8330 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
8331 CHECK(!owner->result_ok);
8332         return DecodeError_clone(&*owner->contents.err);
8333 }
8334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8335         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
8336         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
8337         int64_t ret_ref = 0;
8338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8341         ret_ref = (uintptr_t)ret_var.inner;
8342         if (ret_var.is_owned) {
8343                 ret_ref |= 1;
8344         }
8345         return ret_ref;
8346 }
8347
8348 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8349 CHECK(owner->result_ok);
8350         return NetworkGraph_clone(&*owner->contents.result);
8351 }
8352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8353         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8354         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
8355         int64_t ret_ref = 0;
8356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8359         ret_ref = (uintptr_t)ret_var.inner;
8360         if (ret_var.is_owned) {
8361                 ret_ref |= 1;
8362         }
8363         return ret_ref;
8364 }
8365
8366 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8367 CHECK(!owner->result_ok);
8368         return DecodeError_clone(&*owner->contents.err);
8369 }
8370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8371         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8372         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
8373         int64_t ret_ref = 0;
8374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8377         ret_ref = (uintptr_t)ret_var.inner;
8378         if (ret_var.is_owned) {
8379                 ret_ref |= 1;
8380         }
8381         return ret_ref;
8382 }
8383
8384 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
8385 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
8386 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
8387 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
8388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
8389         LDKCOption_CVec_NetAddressZZ_Some_class =
8390                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
8391         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
8392         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
8393         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
8394         LDKCOption_CVec_NetAddressZZ_None_class =
8395                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
8396         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
8397         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
8398         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
8399 }
8400 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8401         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
8402         switch(obj->tag) {
8403                 case LDKCOption_CVec_NetAddressZZ_Some: {
8404                         LDKCVec_NetAddressZ some_var = obj->some;
8405                         int64_tArray some_arr = NULL;
8406                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
8407                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
8408                         for (size_t m = 0; m < some_var.datalen; m++) {
8409                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
8410                                 some_arr_ptr[m] = some_conv_12_ref;
8411                         }
8412                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
8413                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
8414                 }
8415                 case LDKCOption_CVec_NetAddressZZ_None: {
8416                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
8417                 }
8418                 default: abort();
8419         }
8420 }
8421 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8422 CHECK(owner->result_ok);
8423         return NetAddress_clone(&*owner->contents.result);
8424 }
8425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8426         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8427         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8428         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8429         int64_t ret_ref = (uintptr_t)ret_copy;
8430         return ret_ref;
8431 }
8432
8433 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8434 CHECK(!owner->result_ok);
8435         return DecodeError_clone(&*owner->contents.err);
8436 }
8437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8438         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8439         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8440         int64_t ret_ref = 0;
8441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8444         ret_ref = (uintptr_t)ret_var.inner;
8445         if (ret_var.is_owned) {
8446                 ret_ref |= 1;
8447         }
8448         return ret_ref;
8449 }
8450
8451 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8452         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8453         for (size_t i = 0; i < ret.datalen; i++) {
8454                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8455         }
8456         return ret;
8457 }
8458 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8459         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8460         for (size_t i = 0; i < ret.datalen; i++) {
8461                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8462         }
8463         return ret;
8464 }
8465 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8466         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8467         for (size_t i = 0; i < ret.datalen; i++) {
8468                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8469         }
8470         return ret;
8471 }
8472 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8473         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8474         for (size_t i = 0; i < ret.datalen; i++) {
8475                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8476         }
8477         return ret;
8478 }
8479 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8480 CHECK(owner->result_ok);
8481         return AcceptChannel_clone(&*owner->contents.result);
8482 }
8483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8484         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8485         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8486         int64_t ret_ref = 0;
8487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8490         ret_ref = (uintptr_t)ret_var.inner;
8491         if (ret_var.is_owned) {
8492                 ret_ref |= 1;
8493         }
8494         return ret_ref;
8495 }
8496
8497 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8498 CHECK(!owner->result_ok);
8499         return DecodeError_clone(&*owner->contents.err);
8500 }
8501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8502         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8503         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8504         int64_t ret_ref = 0;
8505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8508         ret_ref = (uintptr_t)ret_var.inner;
8509         if (ret_var.is_owned) {
8510                 ret_ref |= 1;
8511         }
8512         return ret_ref;
8513 }
8514
8515 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8516 CHECK(owner->result_ok);
8517         return AnnouncementSignatures_clone(&*owner->contents.result);
8518 }
8519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8520         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8521         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8522         int64_t ret_ref = 0;
8523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8526         ret_ref = (uintptr_t)ret_var.inner;
8527         if (ret_var.is_owned) {
8528                 ret_ref |= 1;
8529         }
8530         return ret_ref;
8531 }
8532
8533 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8534 CHECK(!owner->result_ok);
8535         return DecodeError_clone(&*owner->contents.err);
8536 }
8537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8538         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8539         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8540         int64_t ret_ref = 0;
8541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8544         ret_ref = (uintptr_t)ret_var.inner;
8545         if (ret_var.is_owned) {
8546                 ret_ref |= 1;
8547         }
8548         return ret_ref;
8549 }
8550
8551 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8552 CHECK(owner->result_ok);
8553         return ChannelReestablish_clone(&*owner->contents.result);
8554 }
8555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8556         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8557         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8558         int64_t ret_ref = 0;
8559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8562         ret_ref = (uintptr_t)ret_var.inner;
8563         if (ret_var.is_owned) {
8564                 ret_ref |= 1;
8565         }
8566         return ret_ref;
8567 }
8568
8569 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8570 CHECK(!owner->result_ok);
8571         return DecodeError_clone(&*owner->contents.err);
8572 }
8573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8574         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8575         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8576         int64_t ret_ref = 0;
8577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8580         ret_ref = (uintptr_t)ret_var.inner;
8581         if (ret_var.is_owned) {
8582                 ret_ref |= 1;
8583         }
8584         return ret_ref;
8585 }
8586
8587 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8588 CHECK(owner->result_ok);
8589         return ClosingSigned_clone(&*owner->contents.result);
8590 }
8591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8592         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8593         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8594         int64_t ret_ref = 0;
8595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8598         ret_ref = (uintptr_t)ret_var.inner;
8599         if (ret_var.is_owned) {
8600                 ret_ref |= 1;
8601         }
8602         return ret_ref;
8603 }
8604
8605 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8606 CHECK(!owner->result_ok);
8607         return DecodeError_clone(&*owner->contents.err);
8608 }
8609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8610         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8611         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8612         int64_t ret_ref = 0;
8613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8616         ret_ref = (uintptr_t)ret_var.inner;
8617         if (ret_var.is_owned) {
8618                 ret_ref |= 1;
8619         }
8620         return ret_ref;
8621 }
8622
8623 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8624 CHECK(owner->result_ok);
8625         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8626 }
8627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8628         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8629         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8630         int64_t ret_ref = 0;
8631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8634         ret_ref = (uintptr_t)ret_var.inner;
8635         if (ret_var.is_owned) {
8636                 ret_ref |= 1;
8637         }
8638         return ret_ref;
8639 }
8640
8641 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8642 CHECK(!owner->result_ok);
8643         return DecodeError_clone(&*owner->contents.err);
8644 }
8645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8646         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8647         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8648         int64_t ret_ref = 0;
8649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8652         ret_ref = (uintptr_t)ret_var.inner;
8653         if (ret_var.is_owned) {
8654                 ret_ref |= 1;
8655         }
8656         return ret_ref;
8657 }
8658
8659 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8660 CHECK(owner->result_ok);
8661         return CommitmentSigned_clone(&*owner->contents.result);
8662 }
8663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8664         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8665         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8666         int64_t ret_ref = 0;
8667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8670         ret_ref = (uintptr_t)ret_var.inner;
8671         if (ret_var.is_owned) {
8672                 ret_ref |= 1;
8673         }
8674         return ret_ref;
8675 }
8676
8677 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8678 CHECK(!owner->result_ok);
8679         return DecodeError_clone(&*owner->contents.err);
8680 }
8681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8682         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8683         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8684         int64_t ret_ref = 0;
8685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8688         ret_ref = (uintptr_t)ret_var.inner;
8689         if (ret_var.is_owned) {
8690                 ret_ref |= 1;
8691         }
8692         return ret_ref;
8693 }
8694
8695 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8696 CHECK(owner->result_ok);
8697         return FundingCreated_clone(&*owner->contents.result);
8698 }
8699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8700         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8701         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8702         int64_t ret_ref = 0;
8703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8706         ret_ref = (uintptr_t)ret_var.inner;
8707         if (ret_var.is_owned) {
8708                 ret_ref |= 1;
8709         }
8710         return ret_ref;
8711 }
8712
8713 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8714 CHECK(!owner->result_ok);
8715         return DecodeError_clone(&*owner->contents.err);
8716 }
8717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8718         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8719         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8720         int64_t ret_ref = 0;
8721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8724         ret_ref = (uintptr_t)ret_var.inner;
8725         if (ret_var.is_owned) {
8726                 ret_ref |= 1;
8727         }
8728         return ret_ref;
8729 }
8730
8731 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8732 CHECK(owner->result_ok);
8733         return FundingSigned_clone(&*owner->contents.result);
8734 }
8735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8736         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8737         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8738         int64_t ret_ref = 0;
8739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8742         ret_ref = (uintptr_t)ret_var.inner;
8743         if (ret_var.is_owned) {
8744                 ret_ref |= 1;
8745         }
8746         return ret_ref;
8747 }
8748
8749 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8750 CHECK(!owner->result_ok);
8751         return DecodeError_clone(&*owner->contents.err);
8752 }
8753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8754         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8755         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8756         int64_t ret_ref = 0;
8757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8760         ret_ref = (uintptr_t)ret_var.inner;
8761         if (ret_var.is_owned) {
8762                 ret_ref |= 1;
8763         }
8764         return ret_ref;
8765 }
8766
8767 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8768 CHECK(owner->result_ok);
8769         return FundingLocked_clone(&*owner->contents.result);
8770 }
8771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8772         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8773         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
8774         int64_t ret_ref = 0;
8775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8778         ret_ref = (uintptr_t)ret_var.inner;
8779         if (ret_var.is_owned) {
8780                 ret_ref |= 1;
8781         }
8782         return ret_ref;
8783 }
8784
8785 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8786 CHECK(!owner->result_ok);
8787         return DecodeError_clone(&*owner->contents.err);
8788 }
8789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8790         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8791         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
8792         int64_t ret_ref = 0;
8793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8796         ret_ref = (uintptr_t)ret_var.inner;
8797         if (ret_var.is_owned) {
8798                 ret_ref |= 1;
8799         }
8800         return ret_ref;
8801 }
8802
8803 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8804 CHECK(owner->result_ok);
8805         return Init_clone(&*owner->contents.result);
8806 }
8807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8808         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8809         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8810         int64_t ret_ref = 0;
8811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8814         ret_ref = (uintptr_t)ret_var.inner;
8815         if (ret_var.is_owned) {
8816                 ret_ref |= 1;
8817         }
8818         return ret_ref;
8819 }
8820
8821 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8822 CHECK(!owner->result_ok);
8823         return DecodeError_clone(&*owner->contents.err);
8824 }
8825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8826         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8827         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8828         int64_t ret_ref = 0;
8829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8832         ret_ref = (uintptr_t)ret_var.inner;
8833         if (ret_var.is_owned) {
8834                 ret_ref |= 1;
8835         }
8836         return ret_ref;
8837 }
8838
8839 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8840 CHECK(owner->result_ok);
8841         return OpenChannel_clone(&*owner->contents.result);
8842 }
8843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8844         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8845         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8846         int64_t ret_ref = 0;
8847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8850         ret_ref = (uintptr_t)ret_var.inner;
8851         if (ret_var.is_owned) {
8852                 ret_ref |= 1;
8853         }
8854         return ret_ref;
8855 }
8856
8857 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8858 CHECK(!owner->result_ok);
8859         return DecodeError_clone(&*owner->contents.err);
8860 }
8861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8862         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8863         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8864         int64_t ret_ref = 0;
8865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8868         ret_ref = (uintptr_t)ret_var.inner;
8869         if (ret_var.is_owned) {
8870                 ret_ref |= 1;
8871         }
8872         return ret_ref;
8873 }
8874
8875 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8876 CHECK(owner->result_ok);
8877         return RevokeAndACK_clone(&*owner->contents.result);
8878 }
8879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8880         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8881         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8882         int64_t ret_ref = 0;
8883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8886         ret_ref = (uintptr_t)ret_var.inner;
8887         if (ret_var.is_owned) {
8888                 ret_ref |= 1;
8889         }
8890         return ret_ref;
8891 }
8892
8893 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8894 CHECK(!owner->result_ok);
8895         return DecodeError_clone(&*owner->contents.err);
8896 }
8897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8898         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8899         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8900         int64_t ret_ref = 0;
8901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8904         ret_ref = (uintptr_t)ret_var.inner;
8905         if (ret_var.is_owned) {
8906                 ret_ref |= 1;
8907         }
8908         return ret_ref;
8909 }
8910
8911 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8912 CHECK(owner->result_ok);
8913         return Shutdown_clone(&*owner->contents.result);
8914 }
8915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8916         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8917         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8918         int64_t ret_ref = 0;
8919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8922         ret_ref = (uintptr_t)ret_var.inner;
8923         if (ret_var.is_owned) {
8924                 ret_ref |= 1;
8925         }
8926         return ret_ref;
8927 }
8928
8929 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8930 CHECK(!owner->result_ok);
8931         return DecodeError_clone(&*owner->contents.err);
8932 }
8933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8934         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8935         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8936         int64_t ret_ref = 0;
8937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8940         ret_ref = (uintptr_t)ret_var.inner;
8941         if (ret_var.is_owned) {
8942                 ret_ref |= 1;
8943         }
8944         return ret_ref;
8945 }
8946
8947 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8948 CHECK(owner->result_ok);
8949         return UpdateFailHTLC_clone(&*owner->contents.result);
8950 }
8951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8952         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8953         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8954         int64_t ret_ref = 0;
8955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8958         ret_ref = (uintptr_t)ret_var.inner;
8959         if (ret_var.is_owned) {
8960                 ret_ref |= 1;
8961         }
8962         return ret_ref;
8963 }
8964
8965 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8966 CHECK(!owner->result_ok);
8967         return DecodeError_clone(&*owner->contents.err);
8968 }
8969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8970         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8971         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8972         int64_t ret_ref = 0;
8973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8976         ret_ref = (uintptr_t)ret_var.inner;
8977         if (ret_var.is_owned) {
8978                 ret_ref |= 1;
8979         }
8980         return ret_ref;
8981 }
8982
8983 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8984 CHECK(owner->result_ok);
8985         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8986 }
8987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8988         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8989         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8990         int64_t ret_ref = 0;
8991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8994         ret_ref = (uintptr_t)ret_var.inner;
8995         if (ret_var.is_owned) {
8996                 ret_ref |= 1;
8997         }
8998         return ret_ref;
8999 }
9000
9001 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9002 CHECK(!owner->result_ok);
9003         return DecodeError_clone(&*owner->contents.err);
9004 }
9005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9006         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9007         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9008         int64_t ret_ref = 0;
9009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9012         ret_ref = (uintptr_t)ret_var.inner;
9013         if (ret_var.is_owned) {
9014                 ret_ref |= 1;
9015         }
9016         return ret_ref;
9017 }
9018
9019 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9020 CHECK(owner->result_ok);
9021         return UpdateFee_clone(&*owner->contents.result);
9022 }
9023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9024         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9025         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9026         int64_t ret_ref = 0;
9027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9030         ret_ref = (uintptr_t)ret_var.inner;
9031         if (ret_var.is_owned) {
9032                 ret_ref |= 1;
9033         }
9034         return ret_ref;
9035 }
9036
9037 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9038 CHECK(!owner->result_ok);
9039         return DecodeError_clone(&*owner->contents.err);
9040 }
9041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9042         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9043         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9044         int64_t ret_ref = 0;
9045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9048         ret_ref = (uintptr_t)ret_var.inner;
9049         if (ret_var.is_owned) {
9050                 ret_ref |= 1;
9051         }
9052         return ret_ref;
9053 }
9054
9055 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9056 CHECK(owner->result_ok);
9057         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9058 }
9059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9060         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9061         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9062         int64_t ret_ref = 0;
9063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9066         ret_ref = (uintptr_t)ret_var.inner;
9067         if (ret_var.is_owned) {
9068                 ret_ref |= 1;
9069         }
9070         return ret_ref;
9071 }
9072
9073 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9074 CHECK(!owner->result_ok);
9075         return DecodeError_clone(&*owner->contents.err);
9076 }
9077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9078         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9079         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9080         int64_t ret_ref = 0;
9081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9084         ret_ref = (uintptr_t)ret_var.inner;
9085         if (ret_var.is_owned) {
9086                 ret_ref |= 1;
9087         }
9088         return ret_ref;
9089 }
9090
9091 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9092 CHECK(owner->result_ok);
9093         return UpdateAddHTLC_clone(&*owner->contents.result);
9094 }
9095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9096         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9097         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9098         int64_t ret_ref = 0;
9099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9102         ret_ref = (uintptr_t)ret_var.inner;
9103         if (ret_var.is_owned) {
9104                 ret_ref |= 1;
9105         }
9106         return ret_ref;
9107 }
9108
9109 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9110 CHECK(!owner->result_ok);
9111         return DecodeError_clone(&*owner->contents.err);
9112 }
9113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9114         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9115         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9116         int64_t ret_ref = 0;
9117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9120         ret_ref = (uintptr_t)ret_var.inner;
9121         if (ret_var.is_owned) {
9122                 ret_ref |= 1;
9123         }
9124         return ret_ref;
9125 }
9126
9127 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9128 CHECK(owner->result_ok);
9129         return Ping_clone(&*owner->contents.result);
9130 }
9131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9132         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9133         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9134         int64_t ret_ref = 0;
9135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9138         ret_ref = (uintptr_t)ret_var.inner;
9139         if (ret_var.is_owned) {
9140                 ret_ref |= 1;
9141         }
9142         return ret_ref;
9143 }
9144
9145 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9146 CHECK(!owner->result_ok);
9147         return DecodeError_clone(&*owner->contents.err);
9148 }
9149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9150         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9151         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9152         int64_t ret_ref = 0;
9153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9156         ret_ref = (uintptr_t)ret_var.inner;
9157         if (ret_var.is_owned) {
9158                 ret_ref |= 1;
9159         }
9160         return ret_ref;
9161 }
9162
9163 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9164 CHECK(owner->result_ok);
9165         return Pong_clone(&*owner->contents.result);
9166 }
9167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9168         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9169         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9170         int64_t ret_ref = 0;
9171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9174         ret_ref = (uintptr_t)ret_var.inner;
9175         if (ret_var.is_owned) {
9176                 ret_ref |= 1;
9177         }
9178         return ret_ref;
9179 }
9180
9181 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9182 CHECK(!owner->result_ok);
9183         return DecodeError_clone(&*owner->contents.err);
9184 }
9185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9186         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9187         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9188         int64_t ret_ref = 0;
9189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9192         ret_ref = (uintptr_t)ret_var.inner;
9193         if (ret_var.is_owned) {
9194                 ret_ref |= 1;
9195         }
9196         return ret_ref;
9197 }
9198
9199 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9200 CHECK(owner->result_ok);
9201         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9202 }
9203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9204         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9205         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9206         int64_t ret_ref = 0;
9207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9210         ret_ref = (uintptr_t)ret_var.inner;
9211         if (ret_var.is_owned) {
9212                 ret_ref |= 1;
9213         }
9214         return ret_ref;
9215 }
9216
9217 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9218 CHECK(!owner->result_ok);
9219         return DecodeError_clone(&*owner->contents.err);
9220 }
9221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9222         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9223         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9224         int64_t ret_ref = 0;
9225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9228         ret_ref = (uintptr_t)ret_var.inner;
9229         if (ret_var.is_owned) {
9230                 ret_ref |= 1;
9231         }
9232         return ret_ref;
9233 }
9234
9235 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9236 CHECK(owner->result_ok);
9237         return ChannelAnnouncement_clone(&*owner->contents.result);
9238 }
9239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9240         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9241         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9242         int64_t ret_ref = 0;
9243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9246         ret_ref = (uintptr_t)ret_var.inner;
9247         if (ret_var.is_owned) {
9248                 ret_ref |= 1;
9249         }
9250         return ret_ref;
9251 }
9252
9253 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9254 CHECK(!owner->result_ok);
9255         return DecodeError_clone(&*owner->contents.err);
9256 }
9257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9258         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9259         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9260         int64_t ret_ref = 0;
9261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9264         ret_ref = (uintptr_t)ret_var.inner;
9265         if (ret_var.is_owned) {
9266                 ret_ref |= 1;
9267         }
9268         return ret_ref;
9269 }
9270
9271 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9272 CHECK(owner->result_ok);
9273         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9274 }
9275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9276         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9277         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9278         int64_t ret_ref = 0;
9279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9282         ret_ref = (uintptr_t)ret_var.inner;
9283         if (ret_var.is_owned) {
9284                 ret_ref |= 1;
9285         }
9286         return ret_ref;
9287 }
9288
9289 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9290 CHECK(!owner->result_ok);
9291         return DecodeError_clone(&*owner->contents.err);
9292 }
9293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9294         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9295         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9296         int64_t ret_ref = 0;
9297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9300         ret_ref = (uintptr_t)ret_var.inner;
9301         if (ret_var.is_owned) {
9302                 ret_ref |= 1;
9303         }
9304         return ret_ref;
9305 }
9306
9307 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9308 CHECK(owner->result_ok);
9309         return ChannelUpdate_clone(&*owner->contents.result);
9310 }
9311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9312         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9313         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9314         int64_t ret_ref = 0;
9315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9318         ret_ref = (uintptr_t)ret_var.inner;
9319         if (ret_var.is_owned) {
9320                 ret_ref |= 1;
9321         }
9322         return ret_ref;
9323 }
9324
9325 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9326 CHECK(!owner->result_ok);
9327         return DecodeError_clone(&*owner->contents.err);
9328 }
9329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9330         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9331         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9332         int64_t ret_ref = 0;
9333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9336         ret_ref = (uintptr_t)ret_var.inner;
9337         if (ret_var.is_owned) {
9338                 ret_ref |= 1;
9339         }
9340         return ret_ref;
9341 }
9342
9343 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9344 CHECK(owner->result_ok);
9345         return ErrorMessage_clone(&*owner->contents.result);
9346 }
9347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9348         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9349         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9350         int64_t ret_ref = 0;
9351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9354         ret_ref = (uintptr_t)ret_var.inner;
9355         if (ret_var.is_owned) {
9356                 ret_ref |= 1;
9357         }
9358         return ret_ref;
9359 }
9360
9361 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9362 CHECK(!owner->result_ok);
9363         return DecodeError_clone(&*owner->contents.err);
9364 }
9365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9366         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9367         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9368         int64_t ret_ref = 0;
9369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9372         ret_ref = (uintptr_t)ret_var.inner;
9373         if (ret_var.is_owned) {
9374                 ret_ref |= 1;
9375         }
9376         return ret_ref;
9377 }
9378
9379 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9380 CHECK(owner->result_ok);
9381         return WarningMessage_clone(&*owner->contents.result);
9382 }
9383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9384         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9385         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9386         int64_t ret_ref = 0;
9387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9390         ret_ref = (uintptr_t)ret_var.inner;
9391         if (ret_var.is_owned) {
9392                 ret_ref |= 1;
9393         }
9394         return ret_ref;
9395 }
9396
9397 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9398 CHECK(!owner->result_ok);
9399         return DecodeError_clone(&*owner->contents.err);
9400 }
9401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9402         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9403         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9404         int64_t ret_ref = 0;
9405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9408         ret_ref = (uintptr_t)ret_var.inner;
9409         if (ret_var.is_owned) {
9410                 ret_ref |= 1;
9411         }
9412         return ret_ref;
9413 }
9414
9415 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9416 CHECK(owner->result_ok);
9417         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9418 }
9419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9421         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9422         int64_t ret_ref = 0;
9423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9426         ret_ref = (uintptr_t)ret_var.inner;
9427         if (ret_var.is_owned) {
9428                 ret_ref |= 1;
9429         }
9430         return ret_ref;
9431 }
9432
9433 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9434 CHECK(!owner->result_ok);
9435         return DecodeError_clone(&*owner->contents.err);
9436 }
9437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9438         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9439         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9440         int64_t ret_ref = 0;
9441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9444         ret_ref = (uintptr_t)ret_var.inner;
9445         if (ret_var.is_owned) {
9446                 ret_ref |= 1;
9447         }
9448         return ret_ref;
9449 }
9450
9451 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9452 CHECK(owner->result_ok);
9453         return NodeAnnouncement_clone(&*owner->contents.result);
9454 }
9455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9456         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9457         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9458         int64_t ret_ref = 0;
9459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9462         ret_ref = (uintptr_t)ret_var.inner;
9463         if (ret_var.is_owned) {
9464                 ret_ref |= 1;
9465         }
9466         return ret_ref;
9467 }
9468
9469 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9470 CHECK(!owner->result_ok);
9471         return DecodeError_clone(&*owner->contents.err);
9472 }
9473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9474         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9475         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9476         int64_t ret_ref = 0;
9477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9480         ret_ref = (uintptr_t)ret_var.inner;
9481         if (ret_var.is_owned) {
9482                 ret_ref |= 1;
9483         }
9484         return ret_ref;
9485 }
9486
9487 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9488 CHECK(owner->result_ok);
9489         return QueryShortChannelIds_clone(&*owner->contents.result);
9490 }
9491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9492         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9493         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9494         int64_t ret_ref = 0;
9495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9498         ret_ref = (uintptr_t)ret_var.inner;
9499         if (ret_var.is_owned) {
9500                 ret_ref |= 1;
9501         }
9502         return ret_ref;
9503 }
9504
9505 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9506 CHECK(!owner->result_ok);
9507         return DecodeError_clone(&*owner->contents.err);
9508 }
9509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9510         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9511         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9512         int64_t ret_ref = 0;
9513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9516         ret_ref = (uintptr_t)ret_var.inner;
9517         if (ret_var.is_owned) {
9518                 ret_ref |= 1;
9519         }
9520         return ret_ref;
9521 }
9522
9523 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9524 CHECK(owner->result_ok);
9525         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9526 }
9527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9528         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9529         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9530         int64_t ret_ref = 0;
9531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9534         ret_ref = (uintptr_t)ret_var.inner;
9535         if (ret_var.is_owned) {
9536                 ret_ref |= 1;
9537         }
9538         return ret_ref;
9539 }
9540
9541 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9542 CHECK(!owner->result_ok);
9543         return DecodeError_clone(&*owner->contents.err);
9544 }
9545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9546         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9547         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9548         int64_t ret_ref = 0;
9549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9552         ret_ref = (uintptr_t)ret_var.inner;
9553         if (ret_var.is_owned) {
9554                 ret_ref |= 1;
9555         }
9556         return ret_ref;
9557 }
9558
9559 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9560 CHECK(owner->result_ok);
9561         return QueryChannelRange_clone(&*owner->contents.result);
9562 }
9563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9564         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9565         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9566         int64_t ret_ref = 0;
9567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9570         ret_ref = (uintptr_t)ret_var.inner;
9571         if (ret_var.is_owned) {
9572                 ret_ref |= 1;
9573         }
9574         return ret_ref;
9575 }
9576
9577 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9578 CHECK(!owner->result_ok);
9579         return DecodeError_clone(&*owner->contents.err);
9580 }
9581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9582         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9583         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9584         int64_t ret_ref = 0;
9585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9588         ret_ref = (uintptr_t)ret_var.inner;
9589         if (ret_var.is_owned) {
9590                 ret_ref |= 1;
9591         }
9592         return ret_ref;
9593 }
9594
9595 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9596 CHECK(owner->result_ok);
9597         return ReplyChannelRange_clone(&*owner->contents.result);
9598 }
9599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9600         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9601         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9602         int64_t ret_ref = 0;
9603         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9604         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9606         ret_ref = (uintptr_t)ret_var.inner;
9607         if (ret_var.is_owned) {
9608                 ret_ref |= 1;
9609         }
9610         return ret_ref;
9611 }
9612
9613 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9614 CHECK(!owner->result_ok);
9615         return DecodeError_clone(&*owner->contents.err);
9616 }
9617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9618         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9619         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9620         int64_t ret_ref = 0;
9621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9624         ret_ref = (uintptr_t)ret_var.inner;
9625         if (ret_var.is_owned) {
9626                 ret_ref |= 1;
9627         }
9628         return ret_ref;
9629 }
9630
9631 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9632 CHECK(owner->result_ok);
9633         return GossipTimestampFilter_clone(&*owner->contents.result);
9634 }
9635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9636         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9637         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9638         int64_t ret_ref = 0;
9639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9642         ret_ref = (uintptr_t)ret_var.inner;
9643         if (ret_var.is_owned) {
9644                 ret_ref |= 1;
9645         }
9646         return ret_ref;
9647 }
9648
9649 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9650 CHECK(!owner->result_ok);
9651         return DecodeError_clone(&*owner->contents.err);
9652 }
9653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9654         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9655         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9656         int64_t ret_ref = 0;
9657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9660         ret_ref = (uintptr_t)ret_var.inner;
9661         if (ret_var.is_owned) {
9662                 ret_ref |= 1;
9663         }
9664         return ret_ref;
9665 }
9666
9667 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9668         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9669         for (size_t i = 0; i < ret.datalen; i++) {
9670                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9671         }
9672         return ret;
9673 }
9674 static jclass LDKSignOrCreationError_SignError_class = NULL;
9675 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9676 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9677 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9679         LDKSignOrCreationError_SignError_class =
9680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9681         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9682         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9683         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9684         LDKSignOrCreationError_CreationError_class =
9685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9686         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9687         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9688         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9689 }
9690 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9691         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9692         switch(obj->tag) {
9693                 case LDKSignOrCreationError_SignError: {
9694                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9695                 }
9696                 case LDKSignOrCreationError_CreationError: {
9697                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9698                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9699                 }
9700                 default: abort();
9701         }
9702 }
9703 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9704 CHECK(owner->result_ok);
9705         return Invoice_clone(&*owner->contents.result);
9706 }
9707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9708         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9709         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9710         int64_t ret_ref = 0;
9711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9714         ret_ref = (uintptr_t)ret_var.inner;
9715         if (ret_var.is_owned) {
9716                 ret_ref |= 1;
9717         }
9718         return ret_ref;
9719 }
9720
9721 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9722 CHECK(!owner->result_ok);
9723         return SignOrCreationError_clone(&*owner->contents.err);
9724 }
9725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9726         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9727         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9728         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9729         int64_t ret_ref = (uintptr_t)ret_copy;
9730         return ret_ref;
9731 }
9732
9733 typedef struct LDKFilter_JCalls {
9734         atomic_size_t refcnt;
9735         JavaVM *vm;
9736         jweak o;
9737         jmethodID register_tx_meth;
9738         jmethodID register_output_meth;
9739 } LDKFilter_JCalls;
9740 static void LDKFilter_JCalls_free(void* this_arg) {
9741         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9742         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9743                 JNIEnv *env;
9744                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9745                 if (get_jenv_res == JNI_EDETACHED) {
9746                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9747                 } else {
9748                         DO_ASSERT(get_jenv_res == JNI_OK);
9749                 }
9750                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9751                 if (get_jenv_res == JNI_EDETACHED) {
9752                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9753                 }
9754                 FREE(j_calls);
9755         }
9756 }
9757 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9758         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9759         JNIEnv *env;
9760         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9761         if (get_jenv_res == JNI_EDETACHED) {
9762                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9763         } else {
9764                 DO_ASSERT(get_jenv_res == JNI_OK);
9765         }
9766         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9767         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9768         LDKu8slice script_pubkey_var = script_pubkey;
9769         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9770         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9772         CHECK(obj != NULL);
9773         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9774         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9775                 (*env)->ExceptionDescribe(env);
9776                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9777         }
9778         if (get_jenv_res == JNI_EDETACHED) {
9779                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9780         }
9781 }
9782 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9783         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9784         JNIEnv *env;
9785         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9786         if (get_jenv_res == JNI_EDETACHED) {
9787                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9788         } else {
9789                 DO_ASSERT(get_jenv_res == JNI_OK);
9790         }
9791         LDKWatchedOutput output_var = output;
9792         int64_t output_ref = 0;
9793         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9794         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9795         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9796         output_ref = (uintptr_t)output_var.inner;
9797         if (output_var.is_owned) {
9798                 output_ref |= 1;
9799         }
9800         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9801         CHECK(obj != NULL);
9802         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9803         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9804                 (*env)->ExceptionDescribe(env);
9805                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9806         }
9807         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9808         CHECK_ACCESS(ret_ptr);
9809         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9810         FREE((void*)ret);
9811         if (get_jenv_res == JNI_EDETACHED) {
9812                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9813         }
9814         return ret_conv;
9815 }
9816 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9817         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9818         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9819 }
9820 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9821         jclass c = (*env)->GetObjectClass(env, o);
9822         CHECK(c != NULL);
9823         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9824         atomic_init(&calls->refcnt, 1);
9825         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9826         calls->o = (*env)->NewWeakGlobalRef(env, o);
9827         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9828         CHECK(calls->register_tx_meth != NULL);
9829         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9830         CHECK(calls->register_output_meth != NULL);
9831
9832         LDKFilter ret = {
9833                 .this_arg = (void*) calls,
9834                 .register_tx = register_tx_LDKFilter_jcall,
9835                 .register_output = register_output_LDKFilter_jcall,
9836                 .free = LDKFilter_JCalls_free,
9837         };
9838         return ret;
9839 }
9840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9841         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9842         *res_ptr = LDKFilter_init(env, clz, o);
9843         return (uint64_t)res_ptr;
9844 }
9845 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) {
9846         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9847         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9848         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9849         unsigned char txid_arr[32];
9850         CHECK((*env)->GetArrayLength(env, txid) == 32);
9851         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9852         unsigned char (*txid_ref)[32] = &txid_arr;
9853         LDKu8slice script_pubkey_ref;
9854         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9855         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9856         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9857         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9858 }
9859
9860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9861         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9862         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9863         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9864         LDKWatchedOutput output_conv;
9865         output_conv.inner = (void*)(output & (~1));
9866         output_conv.is_owned = (output & 1) || (output == 0);
9867         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9868         output_conv = WatchedOutput_clone(&output_conv);
9869         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9870         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9871         int64_t ret_ref = (uintptr_t)ret_copy;
9872         return ret_ref;
9873 }
9874
9875 static jclass LDKCOption_FilterZ_Some_class = NULL;
9876 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9877 static jclass LDKCOption_FilterZ_None_class = NULL;
9878 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9880         LDKCOption_FilterZ_Some_class =
9881                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9882         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9883         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9884         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9885         LDKCOption_FilterZ_None_class =
9886                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9887         CHECK(LDKCOption_FilterZ_None_class != NULL);
9888         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9889         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9890 }
9891 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9892         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9893         switch(obj->tag) {
9894                 case LDKCOption_FilterZ_Some: {
9895                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9896                         *some_ret = obj->some;
9897                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9898                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9899                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9900                                 LDKFilter_JCalls_cloned(&(*some_ret));
9901                         }
9902                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
9903                 }
9904                 case LDKCOption_FilterZ_None: {
9905                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9906                 }
9907                 default: abort();
9908         }
9909 }
9910 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9911 CHECK(owner->result_ok);
9912         return &*owner->contents.result;
9913 }
9914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9915         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9916         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9917         int64_t ret_ref = 0;
9918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9921         ret_ref = (uintptr_t)ret_var.inner & ~1;
9922         return ret_ref;
9923 }
9924
9925 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9926 CHECK(!owner->result_ok);
9927         return *owner->contents.err;
9928 }
9929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9930         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9931         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9932 }
9933
9934 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9935         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9936         for (size_t i = 0; i < ret.datalen; i++) {
9937                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9938         }
9939         return ret;
9940 }
9941 typedef struct LDKMessageSendEventsProvider_JCalls {
9942         atomic_size_t refcnt;
9943         JavaVM *vm;
9944         jweak o;
9945         jmethodID get_and_clear_pending_msg_events_meth;
9946 } LDKMessageSendEventsProvider_JCalls;
9947 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9948         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9949         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9950                 JNIEnv *env;
9951                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9952                 if (get_jenv_res == JNI_EDETACHED) {
9953                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9954                 } else {
9955                         DO_ASSERT(get_jenv_res == JNI_OK);
9956                 }
9957                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9958                 if (get_jenv_res == JNI_EDETACHED) {
9959                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9960                 }
9961                 FREE(j_calls);
9962         }
9963 }
9964 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9965         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9966         JNIEnv *env;
9967         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9968         if (get_jenv_res == JNI_EDETACHED) {
9969                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9970         } else {
9971                 DO_ASSERT(get_jenv_res == JNI_OK);
9972         }
9973         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9974         CHECK(obj != NULL);
9975         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9976         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9977                 (*env)->ExceptionDescribe(env);
9978                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9979         }
9980         LDKCVec_MessageSendEventZ ret_constr;
9981         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9982         if (ret_constr.datalen > 0)
9983                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9984         else
9985                 ret_constr.data = NULL;
9986         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9987         for (size_t s = 0; s < ret_constr.datalen; s++) {
9988                 int64_t ret_conv_18 = ret_vals[s];
9989                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
9990                 CHECK_ACCESS(ret_conv_18_ptr);
9991                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9992                 FREE((void*)ret_conv_18);
9993                 ret_constr.data[s] = ret_conv_18_conv;
9994         }
9995         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9996         if (get_jenv_res == JNI_EDETACHED) {
9997                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9998         }
9999         return ret_constr;
10000 }
10001 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10002         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10003         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10004 }
10005 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10006         jclass c = (*env)->GetObjectClass(env, o);
10007         CHECK(c != NULL);
10008         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10009         atomic_init(&calls->refcnt, 1);
10010         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10011         calls->o = (*env)->NewWeakGlobalRef(env, o);
10012         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10013         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10014
10015         LDKMessageSendEventsProvider ret = {
10016                 .this_arg = (void*) calls,
10017                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10018                 .free = LDKMessageSendEventsProvider_JCalls_free,
10019         };
10020         return ret;
10021 }
10022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10023         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10024         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10025         return (uint64_t)res_ptr;
10026 }
10027 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10028         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10029         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10030         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10031         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10032         int64_tArray ret_arr = NULL;
10033         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10034         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10035         for (size_t s = 0; s < ret_var.datalen; s++) {
10036                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10037                 *ret_conv_18_copy = ret_var.data[s];
10038                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10039                 ret_arr_ptr[s] = ret_conv_18_ref;
10040         }
10041         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10042         FREE(ret_var.data);
10043         return ret_arr;
10044 }
10045
10046 typedef struct LDKEventHandler_JCalls {
10047         atomic_size_t refcnt;
10048         JavaVM *vm;
10049         jweak o;
10050         jmethodID handle_event_meth;
10051 } LDKEventHandler_JCalls;
10052 static void LDKEventHandler_JCalls_free(void* this_arg) {
10053         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10054         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10055                 JNIEnv *env;
10056                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10057                 if (get_jenv_res == JNI_EDETACHED) {
10058                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10059                 } else {
10060                         DO_ASSERT(get_jenv_res == JNI_OK);
10061                 }
10062                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10063                 if (get_jenv_res == JNI_EDETACHED) {
10064                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10065                 }
10066                 FREE(j_calls);
10067         }
10068 }
10069 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10070         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10071         JNIEnv *env;
10072         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10073         if (get_jenv_res == JNI_EDETACHED) {
10074                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10075         } else {
10076                 DO_ASSERT(get_jenv_res == JNI_OK);
10077         }
10078         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10079         *ret_event = Event_clone(event);
10080         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10081         CHECK(obj != NULL);
10082         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10083         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10084                 (*env)->ExceptionDescribe(env);
10085                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10086         }
10087         if (get_jenv_res == JNI_EDETACHED) {
10088                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10089         }
10090 }
10091 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10092         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10093         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10094 }
10095 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10096         jclass c = (*env)->GetObjectClass(env, o);
10097         CHECK(c != NULL);
10098         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10099         atomic_init(&calls->refcnt, 1);
10100         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10101         calls->o = (*env)->NewWeakGlobalRef(env, o);
10102         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10103         CHECK(calls->handle_event_meth != NULL);
10104
10105         LDKEventHandler ret = {
10106                 .this_arg = (void*) calls,
10107                 .handle_event = handle_event_LDKEventHandler_jcall,
10108                 .free = LDKEventHandler_JCalls_free,
10109         };
10110         return ret;
10111 }
10112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10113         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10114         *res_ptr = LDKEventHandler_init(env, clz, o);
10115         return (uint64_t)res_ptr;
10116 }
10117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10118         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10120         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10121         LDKEvent* event_conv = (LDKEvent*)event;
10122         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10123 }
10124
10125 typedef struct LDKEventsProvider_JCalls {
10126         atomic_size_t refcnt;
10127         JavaVM *vm;
10128         jweak o;
10129         jmethodID process_pending_events_meth;
10130 } LDKEventsProvider_JCalls;
10131 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10132         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10133         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10134                 JNIEnv *env;
10135                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10136                 if (get_jenv_res == JNI_EDETACHED) {
10137                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10138                 } else {
10139                         DO_ASSERT(get_jenv_res == JNI_OK);
10140                 }
10141                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10142                 if (get_jenv_res == JNI_EDETACHED) {
10143                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10144                 }
10145                 FREE(j_calls);
10146         }
10147 }
10148 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10149         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10150         JNIEnv *env;
10151         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10152         if (get_jenv_res == JNI_EDETACHED) {
10153                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10154         } else {
10155                 DO_ASSERT(get_jenv_res == JNI_OK);
10156         }
10157         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10158         *handler_ret = handler;
10159         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10160         CHECK(obj != NULL);
10161         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10162         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10163                 (*env)->ExceptionDescribe(env);
10164                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10165         }
10166         if (get_jenv_res == JNI_EDETACHED) {
10167                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10168         }
10169 }
10170 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10171         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10172         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10173 }
10174 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10175         jclass c = (*env)->GetObjectClass(env, o);
10176         CHECK(c != NULL);
10177         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10178         atomic_init(&calls->refcnt, 1);
10179         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10180         calls->o = (*env)->NewWeakGlobalRef(env, o);
10181         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10182         CHECK(calls->process_pending_events_meth != NULL);
10183
10184         LDKEventsProvider ret = {
10185                 .this_arg = (void*) calls,
10186                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10187                 .free = LDKEventsProvider_JCalls_free,
10188         };
10189         return ret;
10190 }
10191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10192         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10193         *res_ptr = LDKEventsProvider_init(env, clz, o);
10194         return (uint64_t)res_ptr;
10195 }
10196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10197         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10198         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10199         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10200         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10201         CHECK_ACCESS(handler_ptr);
10202         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10203         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10205                 LDKEventHandler_JCalls_cloned(&handler_conv);
10206         }
10207         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10208 }
10209
10210 typedef struct LDKListen_JCalls {
10211         atomic_size_t refcnt;
10212         JavaVM *vm;
10213         jweak o;
10214         jmethodID block_connected_meth;
10215         jmethodID block_disconnected_meth;
10216 } LDKListen_JCalls;
10217 static void LDKListen_JCalls_free(void* this_arg) {
10218         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10219         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10220                 JNIEnv *env;
10221                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10222                 if (get_jenv_res == JNI_EDETACHED) {
10223                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10224                 } else {
10225                         DO_ASSERT(get_jenv_res == JNI_OK);
10226                 }
10227                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10228                 if (get_jenv_res == JNI_EDETACHED) {
10229                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10230                 }
10231                 FREE(j_calls);
10232         }
10233 }
10234 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10235         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10236         JNIEnv *env;
10237         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10238         if (get_jenv_res == JNI_EDETACHED) {
10239                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10240         } else {
10241                 DO_ASSERT(get_jenv_res == JNI_OK);
10242         }
10243         LDKu8slice block_var = block;
10244         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10245         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10246         int32_t height_conv = height;
10247         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10248         CHECK(obj != NULL);
10249         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
10250         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10251                 (*env)->ExceptionDescribe(env);
10252                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10253         }
10254         if (get_jenv_res == JNI_EDETACHED) {
10255                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10256         }
10257 }
10258 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10259         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10260         JNIEnv *env;
10261         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10262         if (get_jenv_res == JNI_EDETACHED) {
10263                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10264         } else {
10265                 DO_ASSERT(get_jenv_res == JNI_OK);
10266         }
10267         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10268         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10269         int32_t height_conv = height;
10270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10271         CHECK(obj != NULL);
10272         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
10273         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10274                 (*env)->ExceptionDescribe(env);
10275                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
10276         }
10277         if (get_jenv_res == JNI_EDETACHED) {
10278                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10279         }
10280 }
10281 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
10282         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
10283         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10284 }
10285 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
10286         jclass c = (*env)->GetObjectClass(env, o);
10287         CHECK(c != NULL);
10288         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
10289         atomic_init(&calls->refcnt, 1);
10290         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10291         calls->o = (*env)->NewWeakGlobalRef(env, o);
10292         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
10293         CHECK(calls->block_connected_meth != NULL);
10294         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
10295         CHECK(calls->block_disconnected_meth != NULL);
10296
10297         LDKListen ret = {
10298                 .this_arg = (void*) calls,
10299                 .block_connected = block_connected_LDKListen_jcall,
10300                 .block_disconnected = block_disconnected_LDKListen_jcall,
10301                 .free = LDKListen_JCalls_free,
10302         };
10303         return ret;
10304 }
10305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
10306         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
10307         *res_ptr = LDKListen_init(env, clz, o);
10308         return (uint64_t)res_ptr;
10309 }
10310 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) {
10311         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10312         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10313         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10314         LDKu8slice block_ref;
10315         block_ref.datalen = (*env)->GetArrayLength(env, block);
10316         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
10317         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
10318         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
10319 }
10320
10321 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) {
10322         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10324         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10325         unsigned char header_arr[80];
10326         CHECK((*env)->GetArrayLength(env, header) == 80);
10327         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10328         unsigned char (*header_ref)[80] = &header_arr;
10329         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
10330 }
10331
10332 typedef struct LDKConfirm_JCalls {
10333         atomic_size_t refcnt;
10334         JavaVM *vm;
10335         jweak o;
10336         jmethodID transactions_confirmed_meth;
10337         jmethodID transaction_unconfirmed_meth;
10338         jmethodID best_block_updated_meth;
10339         jmethodID get_relevant_txids_meth;
10340 } LDKConfirm_JCalls;
10341 static void LDKConfirm_JCalls_free(void* this_arg) {
10342         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10343         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10344                 JNIEnv *env;
10345                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10346                 if (get_jenv_res == JNI_EDETACHED) {
10347                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10348                 } else {
10349                         DO_ASSERT(get_jenv_res == JNI_OK);
10350                 }
10351                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10352                 if (get_jenv_res == JNI_EDETACHED) {
10353                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10354                 }
10355                 FREE(j_calls);
10356         }
10357 }
10358 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10359         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10360         JNIEnv *env;
10361         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10362         if (get_jenv_res == JNI_EDETACHED) {
10363                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10364         } else {
10365                 DO_ASSERT(get_jenv_res == JNI_OK);
10366         }
10367         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10368         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10369         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10370         int64_tArray txdata_arr = NULL;
10371         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10372         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10373         for (size_t c = 0; c < txdata_var.datalen; c++) {
10374                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10375                 *txdata_conv_28_conv = txdata_var.data[c];
10376                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10377         }
10378         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10379         FREE(txdata_var.data);
10380         int32_t height_conv = height;
10381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10382         CHECK(obj != NULL);
10383         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
10384         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10385                 (*env)->ExceptionDescribe(env);
10386                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
10387         }
10388         if (get_jenv_res == JNI_EDETACHED) {
10389                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10390         }
10391 }
10392 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
10393         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10394         JNIEnv *env;
10395         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10396         if (get_jenv_res == JNI_EDETACHED) {
10397                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10398         } else {
10399                 DO_ASSERT(get_jenv_res == JNI_OK);
10400         }
10401         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10402         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10404         CHECK(obj != NULL);
10405         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
10406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10407                 (*env)->ExceptionDescribe(env);
10408                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
10409         }
10410         if (get_jenv_res == JNI_EDETACHED) {
10411                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10412         }
10413 }
10414 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10415         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10416         JNIEnv *env;
10417         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10418         if (get_jenv_res == JNI_EDETACHED) {
10419                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10420         } else {
10421                 DO_ASSERT(get_jenv_res == JNI_OK);
10422         }
10423         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10424         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10425         int32_t height_conv = height;
10426         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10427         CHECK(obj != NULL);
10428         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
10429         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10430                 (*env)->ExceptionDescribe(env);
10431                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm 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 }
10437 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
10438         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10439         JNIEnv *env;
10440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10441         if (get_jenv_res == JNI_EDETACHED) {
10442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10443         } else {
10444                 DO_ASSERT(get_jenv_res == JNI_OK);
10445         }
10446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10447         CHECK(obj != NULL);
10448         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
10449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10450                 (*env)->ExceptionDescribe(env);
10451                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
10452         }
10453         LDKCVec_TxidZ ret_constr;
10454         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10455         if (ret_constr.datalen > 0)
10456                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10457         else
10458                 ret_constr.data = NULL;
10459         for (size_t i = 0; i < ret_constr.datalen; i++) {
10460                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
10461                 LDKThirtyTwoBytes ret_conv_8_ref;
10462                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
10463                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
10464                 ret_constr.data[i] = ret_conv_8_ref;
10465         }
10466         if (get_jenv_res == JNI_EDETACHED) {
10467                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10468         }
10469         return ret_constr;
10470 }
10471 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
10472         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
10473         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10474 }
10475 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
10476         jclass c = (*env)->GetObjectClass(env, o);
10477         CHECK(c != NULL);
10478         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
10479         atomic_init(&calls->refcnt, 1);
10480         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10481         calls->o = (*env)->NewWeakGlobalRef(env, o);
10482         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
10483         CHECK(calls->transactions_confirmed_meth != NULL);
10484         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
10485         CHECK(calls->transaction_unconfirmed_meth != NULL);
10486         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
10487         CHECK(calls->best_block_updated_meth != NULL);
10488         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
10489         CHECK(calls->get_relevant_txids_meth != NULL);
10490
10491         LDKConfirm ret = {
10492                 .this_arg = (void*) calls,
10493                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
10494                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
10495                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
10496                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
10497                 .free = LDKConfirm_JCalls_free,
10498         };
10499         return ret;
10500 }
10501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
10502         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
10503         *res_ptr = LDKConfirm_init(env, clz, o);
10504         return (uint64_t)res_ptr;
10505 }
10506 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) {
10507         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10508         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10509         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10510         unsigned char header_arr[80];
10511         CHECK((*env)->GetArrayLength(env, header) == 80);
10512         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10513         unsigned char (*header_ref)[80] = &header_arr;
10514         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10515         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10516         if (txdata_constr.datalen > 0)
10517                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10518         else
10519                 txdata_constr.data = NULL;
10520         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10521         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10522                 int64_t txdata_conv_28 = txdata_vals[c];
10523                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
10524                 CHECK_ACCESS(txdata_conv_28_ptr);
10525                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10526                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
10527                 txdata_constr.data[c] = txdata_conv_28_conv;
10528         }
10529         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10530         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10531 }
10532
10533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
10534         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10535         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10536         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10537         unsigned char txid_arr[32];
10538         CHECK((*env)->GetArrayLength(env, txid) == 32);
10539         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10540         unsigned char (*txid_ref)[32] = &txid_arr;
10541         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
10542 }
10543
10544 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) {
10545         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10546         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10547         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10548         unsigned char header_arr[80];
10549         CHECK((*env)->GetArrayLength(env, header) == 80);
10550         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10551         unsigned char (*header_ref)[80] = &header_arr;
10552         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
10553 }
10554
10555 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
10556         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10557         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10558         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10559         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
10560         jobjectArray ret_arr = NULL;
10561         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10562         ;
10563         for (size_t i = 0; i < ret_var.datalen; i++) {
10564                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
10565                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
10566                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10567         }
10568         
10569         FREE(ret_var.data);
10570         return ret_arr;
10571 }
10572
10573 typedef struct LDKPersist_JCalls {
10574         atomic_size_t refcnt;
10575         JavaVM *vm;
10576         jweak o;
10577         jmethodID persist_new_channel_meth;
10578         jmethodID update_persisted_channel_meth;
10579 } LDKPersist_JCalls;
10580 static void LDKPersist_JCalls_free(void* this_arg) {
10581         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10582         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10583                 JNIEnv *env;
10584                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10585                 if (get_jenv_res == JNI_EDETACHED) {
10586                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10587                 } else {
10588                         DO_ASSERT(get_jenv_res == JNI_OK);
10589                 }
10590                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10591                 if (get_jenv_res == JNI_EDETACHED) {
10592                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10593                 }
10594                 FREE(j_calls);
10595         }
10596 }
10597 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10598         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10599         JNIEnv *env;
10600         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10601         if (get_jenv_res == JNI_EDETACHED) {
10602                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10603         } else {
10604                 DO_ASSERT(get_jenv_res == JNI_OK);
10605         }
10606         LDKOutPoint channel_id_var = channel_id;
10607         int64_t channel_id_ref = 0;
10608         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10609         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10610         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10611         channel_id_ref = (uintptr_t)channel_id_var.inner;
10612         if (channel_id_var.is_owned) {
10613                 channel_id_ref |= 1;
10614         }
10615         LDKChannelMonitor data_var = *data;
10616         int64_t data_ref = 0;
10617         data_var = ChannelMonitor_clone(&data_var);
10618         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10619         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10620         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10621         data_ref = (uintptr_t)data_var.inner;
10622         if (data_var.is_owned) {
10623                 data_ref |= 1;
10624         }
10625         LDKMonitorUpdateId update_id_var = update_id;
10626         int64_t update_id_ref = 0;
10627         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10628         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10629         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10630         update_id_ref = (uintptr_t)update_id_var.inner;
10631         if (update_id_var.is_owned) {
10632                 update_id_ref |= 1;
10633         }
10634         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10635         CHECK(obj != NULL);
10636         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
10637         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10638                 (*env)->ExceptionDescribe(env);
10639                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
10640         }
10641         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10642         CHECK_ACCESS(ret_ptr);
10643         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10644         FREE((void*)ret);
10645         if (get_jenv_res == JNI_EDETACHED) {
10646                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10647         }
10648         return ret_conv;
10649 }
10650 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10651         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10652         JNIEnv *env;
10653         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10654         if (get_jenv_res == JNI_EDETACHED) {
10655                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10656         } else {
10657                 DO_ASSERT(get_jenv_res == JNI_OK);
10658         }
10659         LDKOutPoint channel_id_var = channel_id;
10660         int64_t channel_id_ref = 0;
10661         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10662         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10663         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10664         channel_id_ref = (uintptr_t)channel_id_var.inner;
10665         if (channel_id_var.is_owned) {
10666                 channel_id_ref |= 1;
10667         }
10668         LDKChannelMonitorUpdate update_var = *update;
10669         int64_t update_ref = 0;
10670         if ((uintptr_t)update_var.inner > 4096) {
10671                 update_var = ChannelMonitorUpdate_clone(&update_var);
10672                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10673                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10674         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
10675                 update_ref = (uintptr_t)update_var.inner;
10676                 if (update_var.is_owned) {
10677                         update_ref |= 1;
10678                 }
10679         }
10680         LDKChannelMonitor data_var = *data;
10681         int64_t data_ref = 0;
10682         data_var = ChannelMonitor_clone(&data_var);
10683         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10684         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10685         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10686         data_ref = (uintptr_t)data_var.inner;
10687         if (data_var.is_owned) {
10688                 data_ref |= 1;
10689         }
10690         LDKMonitorUpdateId update_id_var = update_id;
10691         int64_t update_id_ref = 0;
10692         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10693         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10694         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10695         update_id_ref = (uintptr_t)update_id_var.inner;
10696         if (update_id_var.is_owned) {
10697                 update_id_ref |= 1;
10698         }
10699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10700         CHECK(obj != NULL);
10701         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
10702         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10703                 (*env)->ExceptionDescribe(env);
10704                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
10705         }
10706         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10707         CHECK_ACCESS(ret_ptr);
10708         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10709         FREE((void*)ret);
10710         if (get_jenv_res == JNI_EDETACHED) {
10711                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10712         }
10713         return ret_conv;
10714 }
10715 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
10716         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
10717         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10718 }
10719 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
10720         jclass c = (*env)->GetObjectClass(env, o);
10721         CHECK(c != NULL);
10722         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
10723         atomic_init(&calls->refcnt, 1);
10724         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10725         calls->o = (*env)->NewWeakGlobalRef(env, o);
10726         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
10727         CHECK(calls->persist_new_channel_meth != NULL);
10728         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
10729         CHECK(calls->update_persisted_channel_meth != NULL);
10730
10731         LDKPersist ret = {
10732                 .this_arg = (void*) calls,
10733                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
10734                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
10735                 .free = LDKPersist_JCalls_free,
10736         };
10737         return ret;
10738 }
10739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
10740         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
10741         *res_ptr = LDKPersist_init(env, clz, o);
10742         return (uint64_t)res_ptr;
10743 }
10744 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) {
10745         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10746         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10747         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10748         LDKOutPoint channel_id_conv;
10749         channel_id_conv.inner = (void*)(channel_id & (~1));
10750         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10751         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10752         channel_id_conv = OutPoint_clone(&channel_id_conv);
10753         LDKChannelMonitor data_conv;
10754         data_conv.inner = (void*)(data & (~1));
10755         data_conv.is_owned = false;
10756         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10757         LDKMonitorUpdateId update_id_conv;
10758         update_id_conv.inner = (void*)(update_id & (~1));
10759         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10760         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10761         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10762         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10763         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
10764         return (int64_t)ret_conv;
10765 }
10766
10767 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) {
10768         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10769         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10770         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10771         LDKOutPoint channel_id_conv;
10772         channel_id_conv.inner = (void*)(channel_id & (~1));
10773         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10774         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10775         channel_id_conv = OutPoint_clone(&channel_id_conv);
10776         LDKChannelMonitorUpdate update_conv;
10777         update_conv.inner = (void*)(update & (~1));
10778         update_conv.is_owned = false;
10779         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
10780         LDKChannelMonitor data_conv;
10781         data_conv.inner = (void*)(data & (~1));
10782         data_conv.is_owned = false;
10783         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10784         LDKMonitorUpdateId update_id_conv;
10785         update_id_conv.inner = (void*)(update_id & (~1));
10786         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10787         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10788         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10789         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10790         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
10791         return (int64_t)ret_conv;
10792 }
10793
10794 typedef struct LDKChannelMessageHandler_JCalls {
10795         atomic_size_t refcnt;
10796         JavaVM *vm;
10797         jweak o;
10798         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10799         jmethodID handle_open_channel_meth;
10800         jmethodID handle_accept_channel_meth;
10801         jmethodID handle_funding_created_meth;
10802         jmethodID handle_funding_signed_meth;
10803         jmethodID handle_funding_locked_meth;
10804         jmethodID handle_shutdown_meth;
10805         jmethodID handle_closing_signed_meth;
10806         jmethodID handle_update_add_htlc_meth;
10807         jmethodID handle_update_fulfill_htlc_meth;
10808         jmethodID handle_update_fail_htlc_meth;
10809         jmethodID handle_update_fail_malformed_htlc_meth;
10810         jmethodID handle_commitment_signed_meth;
10811         jmethodID handle_revoke_and_ack_meth;
10812         jmethodID handle_update_fee_meth;
10813         jmethodID handle_announcement_signatures_meth;
10814         jmethodID peer_disconnected_meth;
10815         jmethodID peer_connected_meth;
10816         jmethodID handle_channel_reestablish_meth;
10817         jmethodID handle_channel_update_meth;
10818         jmethodID handle_error_meth;
10819 } LDKChannelMessageHandler_JCalls;
10820 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
10821         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10822         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10823                 JNIEnv *env;
10824                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10825                 if (get_jenv_res == JNI_EDETACHED) {
10826                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10827                 } else {
10828                         DO_ASSERT(get_jenv_res == JNI_OK);
10829                 }
10830                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10831                 if (get_jenv_res == JNI_EDETACHED) {
10832                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10833                 }
10834                 FREE(j_calls);
10835         }
10836 }
10837 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
10838         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10839         JNIEnv *env;
10840         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10841         if (get_jenv_res == JNI_EDETACHED) {
10842                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10843         } else {
10844                 DO_ASSERT(get_jenv_res == JNI_OK);
10845         }
10846         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10847         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10848         LDKInitFeatures their_features_var = their_features;
10849         int64_t their_features_ref = 0;
10850         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10851         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10852         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10853         their_features_ref = (uintptr_t)their_features_var.inner;
10854         if (their_features_var.is_owned) {
10855                 their_features_ref |= 1;
10856         }
10857         LDKOpenChannel msg_var = *msg;
10858         int64_t msg_ref = 0;
10859         msg_var = OpenChannel_clone(&msg_var);
10860         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10861         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10862         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10863         msg_ref = (uintptr_t)msg_var.inner;
10864         if (msg_var.is_owned) {
10865                 msg_ref |= 1;
10866         }
10867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10868         CHECK(obj != NULL);
10869         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10870         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10871                 (*env)->ExceptionDescribe(env);
10872                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
10873         }
10874         if (get_jenv_res == JNI_EDETACHED) {
10875                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10876         }
10877 }
10878 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
10879         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10880         JNIEnv *env;
10881         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10882         if (get_jenv_res == JNI_EDETACHED) {
10883                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10884         } else {
10885                 DO_ASSERT(get_jenv_res == JNI_OK);
10886         }
10887         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10888         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10889         LDKInitFeatures their_features_var = their_features;
10890         int64_t their_features_ref = 0;
10891         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10892         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10893         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10894         their_features_ref = (uintptr_t)their_features_var.inner;
10895         if (their_features_var.is_owned) {
10896                 their_features_ref |= 1;
10897         }
10898         LDKAcceptChannel msg_var = *msg;
10899         int64_t msg_ref = 0;
10900         msg_var = AcceptChannel_clone(&msg_var);
10901         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10902         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10903         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10904         msg_ref = (uintptr_t)msg_var.inner;
10905         if (msg_var.is_owned) {
10906                 msg_ref |= 1;
10907         }
10908         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10909         CHECK(obj != NULL);
10910         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10911         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10912                 (*env)->ExceptionDescribe(env);
10913                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10914         }
10915         if (get_jenv_res == JNI_EDETACHED) {
10916                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10917         }
10918 }
10919 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10920         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10921         JNIEnv *env;
10922         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10923         if (get_jenv_res == JNI_EDETACHED) {
10924                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10925         } else {
10926                 DO_ASSERT(get_jenv_res == JNI_OK);
10927         }
10928         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10929         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10930         LDKFundingCreated msg_var = *msg;
10931         int64_t msg_ref = 0;
10932         msg_var = FundingCreated_clone(&msg_var);
10933         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10934         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10935         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10936         msg_ref = (uintptr_t)msg_var.inner;
10937         if (msg_var.is_owned) {
10938                 msg_ref |= 1;
10939         }
10940         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10941         CHECK(obj != NULL);
10942         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10943         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10944                 (*env)->ExceptionDescribe(env);
10945                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10946         }
10947         if (get_jenv_res == JNI_EDETACHED) {
10948                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10949         }
10950 }
10951 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10952         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10953         JNIEnv *env;
10954         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10955         if (get_jenv_res == JNI_EDETACHED) {
10956                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10957         } else {
10958                 DO_ASSERT(get_jenv_res == JNI_OK);
10959         }
10960         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10961         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10962         LDKFundingSigned msg_var = *msg;
10963         int64_t msg_ref = 0;
10964         msg_var = FundingSigned_clone(&msg_var);
10965         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10966         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10967         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10968         msg_ref = (uintptr_t)msg_var.inner;
10969         if (msg_var.is_owned) {
10970                 msg_ref |= 1;
10971         }
10972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10973         CHECK(obj != NULL);
10974         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10975         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10976                 (*env)->ExceptionDescribe(env);
10977                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10978         }
10979         if (get_jenv_res == JNI_EDETACHED) {
10980                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10981         }
10982 }
10983 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
10984         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10985         JNIEnv *env;
10986         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10987         if (get_jenv_res == JNI_EDETACHED) {
10988                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10989         } else {
10990                 DO_ASSERT(get_jenv_res == JNI_OK);
10991         }
10992         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10993         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10994         LDKFundingLocked msg_var = *msg;
10995         int64_t msg_ref = 0;
10996         msg_var = FundingLocked_clone(&msg_var);
10997         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10998         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10999         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11000         msg_ref = (uintptr_t)msg_var.inner;
11001         if (msg_var.is_owned) {
11002                 msg_ref |= 1;
11003         }
11004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11005         CHECK(obj != NULL);
11006         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
11007         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11008                 (*env)->ExceptionDescribe(env);
11009                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
11010         }
11011         if (get_jenv_res == JNI_EDETACHED) {
11012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11013         }
11014 }
11015 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
11016         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11017         JNIEnv *env;
11018         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11019         if (get_jenv_res == JNI_EDETACHED) {
11020                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11021         } else {
11022                 DO_ASSERT(get_jenv_res == JNI_OK);
11023         }
11024         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11025         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11026         LDKInitFeatures their_features_var = *their_features;
11027         int64_t their_features_ref = 0;
11028         their_features_var = InitFeatures_clone(&their_features_var);
11029         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11030         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11031         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11032         their_features_ref = (uintptr_t)their_features_var.inner;
11033         if (their_features_var.is_owned) {
11034                 their_features_ref |= 1;
11035         }
11036         LDKShutdown msg_var = *msg;
11037         int64_t msg_ref = 0;
11038         msg_var = Shutdown_clone(&msg_var);
11039         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11040         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11042         msg_ref = (uintptr_t)msg_var.inner;
11043         if (msg_var.is_owned) {
11044                 msg_ref |= 1;
11045         }
11046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11047         CHECK(obj != NULL);
11048         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11049         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11050                 (*env)->ExceptionDescribe(env);
11051                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11052         }
11053         if (get_jenv_res == JNI_EDETACHED) {
11054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11055         }
11056 }
11057 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11058         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11059         JNIEnv *env;
11060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11061         if (get_jenv_res == JNI_EDETACHED) {
11062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11063         } else {
11064                 DO_ASSERT(get_jenv_res == JNI_OK);
11065         }
11066         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11067         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11068         LDKClosingSigned msg_var = *msg;
11069         int64_t msg_ref = 0;
11070         msg_var = ClosingSigned_clone(&msg_var);
11071         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11072         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11073         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11074         msg_ref = (uintptr_t)msg_var.inner;
11075         if (msg_var.is_owned) {
11076                 msg_ref |= 1;
11077         }
11078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11079         CHECK(obj != NULL);
11080         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11081         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11082                 (*env)->ExceptionDescribe(env);
11083                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11084         }
11085         if (get_jenv_res == JNI_EDETACHED) {
11086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11087         }
11088 }
11089 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11090         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11091         JNIEnv *env;
11092         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11093         if (get_jenv_res == JNI_EDETACHED) {
11094                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11095         } else {
11096                 DO_ASSERT(get_jenv_res == JNI_OK);
11097         }
11098         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11099         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11100         LDKUpdateAddHTLC msg_var = *msg;
11101         int64_t msg_ref = 0;
11102         msg_var = UpdateAddHTLC_clone(&msg_var);
11103         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11104         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11106         msg_ref = (uintptr_t)msg_var.inner;
11107         if (msg_var.is_owned) {
11108                 msg_ref |= 1;
11109         }
11110         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11111         CHECK(obj != NULL);
11112         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11113         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11114                 (*env)->ExceptionDescribe(env);
11115                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11116         }
11117         if (get_jenv_res == JNI_EDETACHED) {
11118                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11119         }
11120 }
11121 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11122         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11123         JNIEnv *env;
11124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11125         if (get_jenv_res == JNI_EDETACHED) {
11126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11127         } else {
11128                 DO_ASSERT(get_jenv_res == JNI_OK);
11129         }
11130         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11131         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11132         LDKUpdateFulfillHTLC msg_var = *msg;
11133         int64_t msg_ref = 0;
11134         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11135         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11136         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11138         msg_ref = (uintptr_t)msg_var.inner;
11139         if (msg_var.is_owned) {
11140                 msg_ref |= 1;
11141         }
11142         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11143         CHECK(obj != NULL);
11144         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11145         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11146                 (*env)->ExceptionDescribe(env);
11147                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11148         }
11149         if (get_jenv_res == JNI_EDETACHED) {
11150                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11151         }
11152 }
11153 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11154         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11155         JNIEnv *env;
11156         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11157         if (get_jenv_res == JNI_EDETACHED) {
11158                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11159         } else {
11160                 DO_ASSERT(get_jenv_res == JNI_OK);
11161         }
11162         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11163         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11164         LDKUpdateFailHTLC msg_var = *msg;
11165         int64_t msg_ref = 0;
11166         msg_var = UpdateFailHTLC_clone(&msg_var);
11167         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11168         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11169         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11170         msg_ref = (uintptr_t)msg_var.inner;
11171         if (msg_var.is_owned) {
11172                 msg_ref |= 1;
11173         }
11174         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11175         CHECK(obj != NULL);
11176         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11177         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11178                 (*env)->ExceptionDescribe(env);
11179                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11180         }
11181         if (get_jenv_res == JNI_EDETACHED) {
11182                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11183         }
11184 }
11185 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11186         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11187         JNIEnv *env;
11188         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11189         if (get_jenv_res == JNI_EDETACHED) {
11190                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11191         } else {
11192                 DO_ASSERT(get_jenv_res == JNI_OK);
11193         }
11194         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11195         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11196         LDKUpdateFailMalformedHTLC msg_var = *msg;
11197         int64_t msg_ref = 0;
11198         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11199         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11200         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11201         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11202         msg_ref = (uintptr_t)msg_var.inner;
11203         if (msg_var.is_owned) {
11204                 msg_ref |= 1;
11205         }
11206         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11207         CHECK(obj != NULL);
11208         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11209         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11210                 (*env)->ExceptionDescribe(env);
11211                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11212         }
11213         if (get_jenv_res == JNI_EDETACHED) {
11214                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11215         }
11216 }
11217 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11218         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11219         JNIEnv *env;
11220         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11221         if (get_jenv_res == JNI_EDETACHED) {
11222                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11223         } else {
11224                 DO_ASSERT(get_jenv_res == JNI_OK);
11225         }
11226         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11227         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11228         LDKCommitmentSigned msg_var = *msg;
11229         int64_t msg_ref = 0;
11230         msg_var = CommitmentSigned_clone(&msg_var);
11231         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11232         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11233         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11234         msg_ref = (uintptr_t)msg_var.inner;
11235         if (msg_var.is_owned) {
11236                 msg_ref |= 1;
11237         }
11238         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11239         CHECK(obj != NULL);
11240         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11241         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11242                 (*env)->ExceptionDescribe(env);
11243                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11244         }
11245         if (get_jenv_res == JNI_EDETACHED) {
11246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11247         }
11248 }
11249 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
11250         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11251         JNIEnv *env;
11252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11253         if (get_jenv_res == JNI_EDETACHED) {
11254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11255         } else {
11256                 DO_ASSERT(get_jenv_res == JNI_OK);
11257         }
11258         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11259         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11260         LDKRevokeAndACK msg_var = *msg;
11261         int64_t msg_ref = 0;
11262         msg_var = RevokeAndACK_clone(&msg_var);
11263         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11264         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11265         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11266         msg_ref = (uintptr_t)msg_var.inner;
11267         if (msg_var.is_owned) {
11268                 msg_ref |= 1;
11269         }
11270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11271         CHECK(obj != NULL);
11272         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
11273         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11274                 (*env)->ExceptionDescribe(env);
11275                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
11276         }
11277         if (get_jenv_res == JNI_EDETACHED) {
11278                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11279         }
11280 }
11281 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
11282         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11283         JNIEnv *env;
11284         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11285         if (get_jenv_res == JNI_EDETACHED) {
11286                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11287         } else {
11288                 DO_ASSERT(get_jenv_res == JNI_OK);
11289         }
11290         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11291         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11292         LDKUpdateFee msg_var = *msg;
11293         int64_t msg_ref = 0;
11294         msg_var = UpdateFee_clone(&msg_var);
11295         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11296         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11297         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11298         msg_ref = (uintptr_t)msg_var.inner;
11299         if (msg_var.is_owned) {
11300                 msg_ref |= 1;
11301         }
11302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11303         CHECK(obj != NULL);
11304         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
11305         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11306                 (*env)->ExceptionDescribe(env);
11307                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
11308         }
11309         if (get_jenv_res == JNI_EDETACHED) {
11310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11311         }
11312 }
11313 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
11314         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11315         JNIEnv *env;
11316         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11317         if (get_jenv_res == JNI_EDETACHED) {
11318                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11319         } else {
11320                 DO_ASSERT(get_jenv_res == JNI_OK);
11321         }
11322         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11323         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11324         LDKAnnouncementSignatures msg_var = *msg;
11325         int64_t msg_ref = 0;
11326         msg_var = AnnouncementSignatures_clone(&msg_var);
11327         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11328         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11329         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11330         msg_ref = (uintptr_t)msg_var.inner;
11331         if (msg_var.is_owned) {
11332                 msg_ref |= 1;
11333         }
11334         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11335         CHECK(obj != NULL);
11336         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
11337         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11338                 (*env)->ExceptionDescribe(env);
11339                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
11340         }
11341         if (get_jenv_res == JNI_EDETACHED) {
11342                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11343         }
11344 }
11345 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
11346         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11347         JNIEnv *env;
11348         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11349         if (get_jenv_res == JNI_EDETACHED) {
11350                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11351         } else {
11352                 DO_ASSERT(get_jenv_res == JNI_OK);
11353         }
11354         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11355         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11356         jboolean no_connection_possible_conv = no_connection_possible;
11357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11358         CHECK(obj != NULL);
11359         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
11360         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11361                 (*env)->ExceptionDescribe(env);
11362                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
11363         }
11364         if (get_jenv_res == JNI_EDETACHED) {
11365                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11366         }
11367 }
11368 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
11369         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11370         JNIEnv *env;
11371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11372         if (get_jenv_res == JNI_EDETACHED) {
11373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11374         } else {
11375                 DO_ASSERT(get_jenv_res == JNI_OK);
11376         }
11377         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11378         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11379         LDKInit msg_var = *msg;
11380         int64_t msg_ref = 0;
11381         msg_var = Init_clone(&msg_var);
11382         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11383         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11384         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11385         msg_ref = (uintptr_t)msg_var.inner;
11386         if (msg_var.is_owned) {
11387                 msg_ref |= 1;
11388         }
11389         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11390         CHECK(obj != NULL);
11391         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
11392         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11393                 (*env)->ExceptionDescribe(env);
11394                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
11395         }
11396         if (get_jenv_res == JNI_EDETACHED) {
11397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11398         }
11399 }
11400 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
11401         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11402         JNIEnv *env;
11403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11404         if (get_jenv_res == JNI_EDETACHED) {
11405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11406         } else {
11407                 DO_ASSERT(get_jenv_res == JNI_OK);
11408         }
11409         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11410         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11411         LDKChannelReestablish msg_var = *msg;
11412         int64_t msg_ref = 0;
11413         msg_var = ChannelReestablish_clone(&msg_var);
11414         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11415         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11416         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11417         msg_ref = (uintptr_t)msg_var.inner;
11418         if (msg_var.is_owned) {
11419                 msg_ref |= 1;
11420         }
11421         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11422         CHECK(obj != NULL);
11423         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
11424         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11425                 (*env)->ExceptionDescribe(env);
11426                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
11427         }
11428         if (get_jenv_res == JNI_EDETACHED) {
11429                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11430         }
11431 }
11432 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
11433         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11434         JNIEnv *env;
11435         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11436         if (get_jenv_res == JNI_EDETACHED) {
11437                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11438         } else {
11439                 DO_ASSERT(get_jenv_res == JNI_OK);
11440         }
11441         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11442         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11443         LDKChannelUpdate msg_var = *msg;
11444         int64_t msg_ref = 0;
11445         msg_var = ChannelUpdate_clone(&msg_var);
11446         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11447         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11448         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11449         msg_ref = (uintptr_t)msg_var.inner;
11450         if (msg_var.is_owned) {
11451                 msg_ref |= 1;
11452         }
11453         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11454         CHECK(obj != NULL);
11455         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
11456         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11457                 (*env)->ExceptionDescribe(env);
11458                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
11459         }
11460         if (get_jenv_res == JNI_EDETACHED) {
11461                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11462         }
11463 }
11464 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
11465         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11466         JNIEnv *env;
11467         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11468         if (get_jenv_res == JNI_EDETACHED) {
11469                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11470         } else {
11471                 DO_ASSERT(get_jenv_res == JNI_OK);
11472         }
11473         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11474         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11475         LDKErrorMessage msg_var = *msg;
11476         int64_t msg_ref = 0;
11477         msg_var = ErrorMessage_clone(&msg_var);
11478         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11479         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11480         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11481         msg_ref = (uintptr_t)msg_var.inner;
11482         if (msg_var.is_owned) {
11483                 msg_ref |= 1;
11484         }
11485         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11486         CHECK(obj != NULL);
11487         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
11488         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11489                 (*env)->ExceptionDescribe(env);
11490                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
11491         }
11492         if (get_jenv_res == JNI_EDETACHED) {
11493                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11494         }
11495 }
11496 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
11497         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
11498         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11499         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11500 }
11501 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11502         jclass c = (*env)->GetObjectClass(env, o);
11503         CHECK(c != NULL);
11504         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
11505         atomic_init(&calls->refcnt, 1);
11506         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11507         calls->o = (*env)->NewWeakGlobalRef(env, o);
11508         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
11509         CHECK(calls->handle_open_channel_meth != NULL);
11510         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
11511         CHECK(calls->handle_accept_channel_meth != NULL);
11512         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
11513         CHECK(calls->handle_funding_created_meth != NULL);
11514         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
11515         CHECK(calls->handle_funding_signed_meth != NULL);
11516         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
11517         CHECK(calls->handle_funding_locked_meth != NULL);
11518         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
11519         CHECK(calls->handle_shutdown_meth != NULL);
11520         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
11521         CHECK(calls->handle_closing_signed_meth != NULL);
11522         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
11523         CHECK(calls->handle_update_add_htlc_meth != NULL);
11524         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
11525         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
11526         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
11527         CHECK(calls->handle_update_fail_htlc_meth != NULL);
11528         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
11529         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
11530         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
11531         CHECK(calls->handle_commitment_signed_meth != NULL);
11532         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
11533         CHECK(calls->handle_revoke_and_ack_meth != NULL);
11534         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
11535         CHECK(calls->handle_update_fee_meth != NULL);
11536         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
11537         CHECK(calls->handle_announcement_signatures_meth != NULL);
11538         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
11539         CHECK(calls->peer_disconnected_meth != NULL);
11540         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
11541         CHECK(calls->peer_connected_meth != NULL);
11542         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
11543         CHECK(calls->handle_channel_reestablish_meth != NULL);
11544         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
11545         CHECK(calls->handle_channel_update_meth != NULL);
11546         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
11547         CHECK(calls->handle_error_meth != NULL);
11548
11549         LDKChannelMessageHandler ret = {
11550                 .this_arg = (void*) calls,
11551                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
11552                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
11553                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
11554                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
11555                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
11556                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
11557                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
11558                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
11559                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
11560                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
11561                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
11562                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
11563                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
11564                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
11565                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
11566                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
11567                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
11568                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
11569                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
11570                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
11571                 .free = LDKChannelMessageHandler_JCalls_free,
11572                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11573         };
11574         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11575         return ret;
11576 }
11577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11578         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11579         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11580         return (uint64_t)res_ptr;
11581 }
11582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11583         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
11584         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11585         DO_ASSERT((res_ptr & 1) == 0);
11586         return (int64_t)(res_ptr | 1);
11587 }
11588 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) {
11589         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11591         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11592         LDKPublicKey their_node_id_ref;
11593         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11594         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11595         LDKInitFeatures their_features_conv;
11596         their_features_conv.inner = (void*)(their_features & (~1));
11597         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11598         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11599         their_features_conv = InitFeatures_clone(&their_features_conv);
11600         LDKOpenChannel msg_conv;
11601         msg_conv.inner = (void*)(msg & (~1));
11602         msg_conv.is_owned = false;
11603         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11604         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11605 }
11606
11607 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) {
11608         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11609         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11610         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11611         LDKPublicKey their_node_id_ref;
11612         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11613         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11614         LDKInitFeatures their_features_conv;
11615         their_features_conv.inner = (void*)(their_features & (~1));
11616         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11617         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11618         their_features_conv = InitFeatures_clone(&their_features_conv);
11619         LDKAcceptChannel msg_conv;
11620         msg_conv.inner = (void*)(msg & (~1));
11621         msg_conv.is_owned = false;
11622         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11623         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11624 }
11625
11626 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) {
11627         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11628         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11629         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11630         LDKPublicKey their_node_id_ref;
11631         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11632         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11633         LDKFundingCreated msg_conv;
11634         msg_conv.inner = (void*)(msg & (~1));
11635         msg_conv.is_owned = false;
11636         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11637         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11638 }
11639
11640 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) {
11641         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11642         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11643         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11644         LDKPublicKey their_node_id_ref;
11645         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11646         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11647         LDKFundingSigned msg_conv;
11648         msg_conv.inner = (void*)(msg & (~1));
11649         msg_conv.is_owned = false;
11650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11651         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11652 }
11653
11654 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) {
11655         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11656         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11657         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11658         LDKPublicKey their_node_id_ref;
11659         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11660         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11661         LDKFundingLocked msg_conv;
11662         msg_conv.inner = (void*)(msg & (~1));
11663         msg_conv.is_owned = false;
11664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11665         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11666 }
11667
11668 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) {
11669         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11670         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11671         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11672         LDKPublicKey their_node_id_ref;
11673         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11674         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11675         LDKInitFeatures their_features_conv;
11676         their_features_conv.inner = (void*)(their_features & (~1));
11677         their_features_conv.is_owned = false;
11678         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11679         LDKShutdown msg_conv;
11680         msg_conv.inner = (void*)(msg & (~1));
11681         msg_conv.is_owned = false;
11682         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11683         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
11684 }
11685
11686 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) {
11687         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11688         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11689         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11690         LDKPublicKey their_node_id_ref;
11691         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11692         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11693         LDKClosingSigned msg_conv;
11694         msg_conv.inner = (void*)(msg & (~1));
11695         msg_conv.is_owned = false;
11696         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11697         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11698 }
11699
11700 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) {
11701         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11702         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11703         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11704         LDKPublicKey their_node_id_ref;
11705         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11706         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11707         LDKUpdateAddHTLC msg_conv;
11708         msg_conv.inner = (void*)(msg & (~1));
11709         msg_conv.is_owned = false;
11710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11711         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11712 }
11713
11714 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) {
11715         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11716         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11717         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11718         LDKPublicKey their_node_id_ref;
11719         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11720         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11721         LDKUpdateFulfillHTLC msg_conv;
11722         msg_conv.inner = (void*)(msg & (~1));
11723         msg_conv.is_owned = false;
11724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11725         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11726 }
11727
11728 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) {
11729         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11730         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11731         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11732         LDKPublicKey their_node_id_ref;
11733         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11734         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11735         LDKUpdateFailHTLC msg_conv;
11736         msg_conv.inner = (void*)(msg & (~1));
11737         msg_conv.is_owned = false;
11738         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11739         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11740 }
11741
11742 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) {
11743         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11746         LDKPublicKey their_node_id_ref;
11747         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11748         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11749         LDKUpdateFailMalformedHTLC msg_conv;
11750         msg_conv.inner = (void*)(msg & (~1));
11751         msg_conv.is_owned = false;
11752         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11753         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11754 }
11755
11756 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) {
11757         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11758         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11759         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11760         LDKPublicKey their_node_id_ref;
11761         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11762         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11763         LDKCommitmentSigned msg_conv;
11764         msg_conv.inner = (void*)(msg & (~1));
11765         msg_conv.is_owned = false;
11766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11767         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11768 }
11769
11770 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) {
11771         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11772         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11773         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11774         LDKPublicKey their_node_id_ref;
11775         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11776         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11777         LDKRevokeAndACK msg_conv;
11778         msg_conv.inner = (void*)(msg & (~1));
11779         msg_conv.is_owned = false;
11780         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11781         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11782 }
11783
11784 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) {
11785         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11786         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11787         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11788         LDKPublicKey their_node_id_ref;
11789         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11790         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11791         LDKUpdateFee msg_conv;
11792         msg_conv.inner = (void*)(msg & (~1));
11793         msg_conv.is_owned = false;
11794         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11795         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11796 }
11797
11798 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) {
11799         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11800         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11801         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11802         LDKPublicKey their_node_id_ref;
11803         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11804         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11805         LDKAnnouncementSignatures msg_conv;
11806         msg_conv.inner = (void*)(msg & (~1));
11807         msg_conv.is_owned = false;
11808         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11809         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11810 }
11811
11812 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) {
11813         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11814         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11815         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11816         LDKPublicKey their_node_id_ref;
11817         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11818         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11819         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
11820 }
11821
11822 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) {
11823         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11824         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11825         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11826         LDKPublicKey their_node_id_ref;
11827         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11828         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11829         LDKInit msg_conv;
11830         msg_conv.inner = (void*)(msg & (~1));
11831         msg_conv.is_owned = false;
11832         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11833         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11834 }
11835
11836 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) {
11837         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11838         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11839         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11840         LDKPublicKey their_node_id_ref;
11841         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11842         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11843         LDKChannelReestablish msg_conv;
11844         msg_conv.inner = (void*)(msg & (~1));
11845         msg_conv.is_owned = false;
11846         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11847         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11848 }
11849
11850 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) {
11851         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11852         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11853         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11854         LDKPublicKey their_node_id_ref;
11855         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11856         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11857         LDKChannelUpdate msg_conv;
11858         msg_conv.inner = (void*)(msg & (~1));
11859         msg_conv.is_owned = false;
11860         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11861         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11862 }
11863
11864 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) {
11865         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11866         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11867         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11868         LDKPublicKey their_node_id_ref;
11869         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11870         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11871         LDKErrorMessage msg_conv;
11872         msg_conv.inner = (void*)(msg & (~1));
11873         msg_conv.is_owned = false;
11874         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11875         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11876 }
11877
11878 typedef struct LDKRoutingMessageHandler_JCalls {
11879         atomic_size_t refcnt;
11880         JavaVM *vm;
11881         jweak o;
11882         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11883         jmethodID handle_node_announcement_meth;
11884         jmethodID handle_channel_announcement_meth;
11885         jmethodID handle_channel_update_meth;
11886         jmethodID get_next_channel_announcements_meth;
11887         jmethodID get_next_node_announcements_meth;
11888         jmethodID peer_connected_meth;
11889         jmethodID handle_reply_channel_range_meth;
11890         jmethodID handle_reply_short_channel_ids_end_meth;
11891         jmethodID handle_query_channel_range_meth;
11892         jmethodID handle_query_short_channel_ids_meth;
11893 } LDKRoutingMessageHandler_JCalls;
11894 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11895         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11896         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11897                 JNIEnv *env;
11898                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11899                 if (get_jenv_res == JNI_EDETACHED) {
11900                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11901                 } else {
11902                         DO_ASSERT(get_jenv_res == JNI_OK);
11903                 }
11904                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11905                 if (get_jenv_res == JNI_EDETACHED) {
11906                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11907                 }
11908                 FREE(j_calls);
11909         }
11910 }
11911 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11912         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11913         JNIEnv *env;
11914         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11915         if (get_jenv_res == JNI_EDETACHED) {
11916                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11917         } else {
11918                 DO_ASSERT(get_jenv_res == JNI_OK);
11919         }
11920         LDKNodeAnnouncement msg_var = *msg;
11921         int64_t msg_ref = 0;
11922         msg_var = NodeAnnouncement_clone(&msg_var);
11923         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11924         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11925         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11926         msg_ref = (uintptr_t)msg_var.inner;
11927         if (msg_var.is_owned) {
11928                 msg_ref |= 1;
11929         }
11930         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11931         CHECK(obj != NULL);
11932         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11933         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11934                 (*env)->ExceptionDescribe(env);
11935                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11936         }
11937         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11938         CHECK_ACCESS(ret_ptr);
11939         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11940         FREE((void*)ret);
11941         if (get_jenv_res == JNI_EDETACHED) {
11942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11943         }
11944         return ret_conv;
11945 }
11946 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11947         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11948         JNIEnv *env;
11949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11950         if (get_jenv_res == JNI_EDETACHED) {
11951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11952         } else {
11953                 DO_ASSERT(get_jenv_res == JNI_OK);
11954         }
11955         LDKChannelAnnouncement msg_var = *msg;
11956         int64_t msg_ref = 0;
11957         msg_var = ChannelAnnouncement_clone(&msg_var);
11958         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11959         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11960         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11961         msg_ref = (uintptr_t)msg_var.inner;
11962         if (msg_var.is_owned) {
11963                 msg_ref |= 1;
11964         }
11965         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11966         CHECK(obj != NULL);
11967         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11968         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11969                 (*env)->ExceptionDescribe(env);
11970                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11971         }
11972         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11973         CHECK_ACCESS(ret_ptr);
11974         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11975         FREE((void*)ret);
11976         if (get_jenv_res == JNI_EDETACHED) {
11977                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11978         }
11979         return ret_conv;
11980 }
11981 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11982         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11983         JNIEnv *env;
11984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11985         if (get_jenv_res == JNI_EDETACHED) {
11986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11987         } else {
11988                 DO_ASSERT(get_jenv_res == JNI_OK);
11989         }
11990         LDKChannelUpdate msg_var = *msg;
11991         int64_t msg_ref = 0;
11992         msg_var = ChannelUpdate_clone(&msg_var);
11993         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11994         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11995         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11996         msg_ref = (uintptr_t)msg_var.inner;
11997         if (msg_var.is_owned) {
11998                 msg_ref |= 1;
11999         }
12000         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12001         CHECK(obj != NULL);
12002         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
12003         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12004                 (*env)->ExceptionDescribe(env);
12005                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
12006         }
12007         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12008         CHECK_ACCESS(ret_ptr);
12009         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12010         FREE((void*)ret);
12011         if (get_jenv_res == JNI_EDETACHED) {
12012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12013         }
12014         return ret_conv;
12015 }
12016 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
12017         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12018         JNIEnv *env;
12019         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12020         if (get_jenv_res == JNI_EDETACHED) {
12021                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12022         } else {
12023                 DO_ASSERT(get_jenv_res == JNI_OK);
12024         }
12025         int64_t starting_point_conv = starting_point;
12026         int8_t batch_amount_conv = batch_amount;
12027         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12028         CHECK(obj != NULL);
12029         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
12030         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12031                 (*env)->ExceptionDescribe(env);
12032                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12033         }
12034         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
12035         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12036         if (ret_constr.datalen > 0)
12037                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
12038         else
12039                 ret_constr.data = NULL;
12040         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12041         for (size_t h = 0; h < ret_constr.datalen; h++) {
12042                 int64_t ret_conv_59 = ret_vals[h];
12043                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
12044                 CHECK_ACCESS(ret_conv_59_ptr);
12045                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
12046                 FREE((void*)ret_conv_59);
12047                 ret_constr.data[h] = ret_conv_59_conv;
12048         }
12049         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12050         if (get_jenv_res == JNI_EDETACHED) {
12051                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12052         }
12053         return ret_constr;
12054 }
12055 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
12056         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12057         JNIEnv *env;
12058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12059         if (get_jenv_res == JNI_EDETACHED) {
12060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12061         } else {
12062                 DO_ASSERT(get_jenv_res == JNI_OK);
12063         }
12064         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12065         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12066         int8_t batch_amount_conv = batch_amount;
12067         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12068         CHECK(obj != NULL);
12069         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
12070         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12071                 (*env)->ExceptionDescribe(env);
12072                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12073         }
12074         LDKCVec_NodeAnnouncementZ ret_constr;
12075         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12076         if (ret_constr.datalen > 0)
12077                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
12078         else
12079                 ret_constr.data = NULL;
12080         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12081         for (size_t s = 0; s < ret_constr.datalen; s++) {
12082                 int64_t ret_conv_18 = ret_vals[s];
12083                 LDKNodeAnnouncement ret_conv_18_conv;
12084                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
12085                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
12086                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
12087                 ret_constr.data[s] = ret_conv_18_conv;
12088         }
12089         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12090         if (get_jenv_res == JNI_EDETACHED) {
12091                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12092         }
12093         return ret_constr;
12094 }
12095 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12096         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12097         JNIEnv *env;
12098         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12099         if (get_jenv_res == JNI_EDETACHED) {
12100                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12101         } else {
12102                 DO_ASSERT(get_jenv_res == JNI_OK);
12103         }
12104         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12105         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12106         LDKInit init_var = *init;
12107         int64_t init_ref = 0;
12108         init_var = Init_clone(&init_var);
12109         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12110         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12111         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12112         init_ref = (uintptr_t)init_var.inner;
12113         if (init_var.is_owned) {
12114                 init_ref |= 1;
12115         }
12116         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12117         CHECK(obj != NULL);
12118         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12119         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12120                 (*env)->ExceptionDescribe(env);
12121                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
12122         }
12123         if (get_jenv_res == JNI_EDETACHED) {
12124                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12125         }
12126 }
12127 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12128         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12129         JNIEnv *env;
12130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12131         if (get_jenv_res == JNI_EDETACHED) {
12132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12133         } else {
12134                 DO_ASSERT(get_jenv_res == JNI_OK);
12135         }
12136         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12137         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12138         LDKReplyChannelRange msg_var = msg;
12139         int64_t msg_ref = 0;
12140         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12141         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12142         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12143         msg_ref = (uintptr_t)msg_var.inner;
12144         if (msg_var.is_owned) {
12145                 msg_ref |= 1;
12146         }
12147         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12148         CHECK(obj != NULL);
12149         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12150         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12151                 (*env)->ExceptionDescribe(env);
12152                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12153         }
12154         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12155         CHECK_ACCESS(ret_ptr);
12156         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12157         FREE((void*)ret);
12158         if (get_jenv_res == JNI_EDETACHED) {
12159                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12160         }
12161         return ret_conv;
12162 }
12163 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12164         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12165         JNIEnv *env;
12166         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12167         if (get_jenv_res == JNI_EDETACHED) {
12168                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12169         } else {
12170                 DO_ASSERT(get_jenv_res == JNI_OK);
12171         }
12172         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12173         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12174         LDKReplyShortChannelIdsEnd msg_var = msg;
12175         int64_t msg_ref = 0;
12176         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12177         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12178         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12179         msg_ref = (uintptr_t)msg_var.inner;
12180         if (msg_var.is_owned) {
12181                 msg_ref |= 1;
12182         }
12183         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12184         CHECK(obj != NULL);
12185         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12186         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12187                 (*env)->ExceptionDescribe(env);
12188                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12189         }
12190         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12191         CHECK_ACCESS(ret_ptr);
12192         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12193         FREE((void*)ret);
12194         if (get_jenv_res == JNI_EDETACHED) {
12195                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12196         }
12197         return ret_conv;
12198 }
12199 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12200         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12201         JNIEnv *env;
12202         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12203         if (get_jenv_res == JNI_EDETACHED) {
12204                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12205         } else {
12206                 DO_ASSERT(get_jenv_res == JNI_OK);
12207         }
12208         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12209         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12210         LDKQueryChannelRange msg_var = msg;
12211         int64_t msg_ref = 0;
12212         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12213         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12214         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12215         msg_ref = (uintptr_t)msg_var.inner;
12216         if (msg_var.is_owned) {
12217                 msg_ref |= 1;
12218         }
12219         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12220         CHECK(obj != NULL);
12221         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12222         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12223                 (*env)->ExceptionDescribe(env);
12224                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12225         }
12226         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12227         CHECK_ACCESS(ret_ptr);
12228         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12229         FREE((void*)ret);
12230         if (get_jenv_res == JNI_EDETACHED) {
12231                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12232         }
12233         return ret_conv;
12234 }
12235 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12236         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12237         JNIEnv *env;
12238         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12239         if (get_jenv_res == JNI_EDETACHED) {
12240                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12241         } else {
12242                 DO_ASSERT(get_jenv_res == JNI_OK);
12243         }
12244         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12245         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12246         LDKQueryShortChannelIds msg_var = msg;
12247         int64_t msg_ref = 0;
12248         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12249         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12251         msg_ref = (uintptr_t)msg_var.inner;
12252         if (msg_var.is_owned) {
12253                 msg_ref |= 1;
12254         }
12255         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12256         CHECK(obj != NULL);
12257         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
12258         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12259                 (*env)->ExceptionDescribe(env);
12260                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
12261         }
12262         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12263         CHECK_ACCESS(ret_ptr);
12264         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12265         FREE((void*)ret);
12266         if (get_jenv_res == JNI_EDETACHED) {
12267                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12268         }
12269         return ret_conv;
12270 }
12271 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
12272         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
12273         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12274         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12275 }
12276 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12277         jclass c = (*env)->GetObjectClass(env, o);
12278         CHECK(c != NULL);
12279         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
12280         atomic_init(&calls->refcnt, 1);
12281         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12282         calls->o = (*env)->NewWeakGlobalRef(env, o);
12283         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
12284         CHECK(calls->handle_node_announcement_meth != NULL);
12285         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
12286         CHECK(calls->handle_channel_announcement_meth != NULL);
12287         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
12288         CHECK(calls->handle_channel_update_meth != NULL);
12289         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
12290         CHECK(calls->get_next_channel_announcements_meth != NULL);
12291         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
12292         CHECK(calls->get_next_node_announcements_meth != NULL);
12293         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12294         CHECK(calls->peer_connected_meth != NULL);
12295         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
12296         CHECK(calls->handle_reply_channel_range_meth != NULL);
12297         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
12298         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
12299         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
12300         CHECK(calls->handle_query_channel_range_meth != NULL);
12301         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
12302         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
12303
12304         LDKRoutingMessageHandler ret = {
12305                 .this_arg = (void*) calls,
12306                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
12307                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
12308                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
12309                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
12310                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
12311                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
12312                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
12313                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
12314                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
12315                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
12316                 .free = LDKRoutingMessageHandler_JCalls_free,
12317                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12318         };
12319         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12320         return ret;
12321 }
12322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12323         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12324         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12325         return (uint64_t)res_ptr;
12326 }
12327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12328         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
12329         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12330         DO_ASSERT((res_ptr & 1) == 0);
12331         return (int64_t)(res_ptr | 1);
12332 }
12333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12334         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12335         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12336         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12337         LDKNodeAnnouncement msg_conv;
12338         msg_conv.inner = (void*)(msg & (~1));
12339         msg_conv.is_owned = false;
12340         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12341         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12342         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
12343         return (int64_t)ret_conv;
12344 }
12345
12346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12347         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12348         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12349         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12350         LDKChannelAnnouncement msg_conv;
12351         msg_conv.inner = (void*)(msg & (~1));
12352         msg_conv.is_owned = false;
12353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12354         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12355         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
12356         return (int64_t)ret_conv;
12357 }
12358
12359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12360         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12361         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12362         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12363         LDKChannelUpdate msg_conv;
12364         msg_conv.inner = (void*)(msg & (~1));
12365         msg_conv.is_owned = false;
12366         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12367         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12368         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
12369         return (int64_t)ret_conv;
12370 }
12371
12372 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) {
12373         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12374         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12375         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12376         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
12377         int64_tArray ret_arr = NULL;
12378         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12379         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12380         for (size_t h = 0; h < ret_var.datalen; h++) {
12381                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
12382                 *ret_conv_59_conv = ret_var.data[h];
12383                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
12384         }
12385         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12386         FREE(ret_var.data);
12387         return ret_arr;
12388 }
12389
12390 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) {
12391         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12392         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12393         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12394         LDKPublicKey starting_point_ref;
12395         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
12396         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
12397         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
12398         int64_tArray ret_arr = NULL;
12399         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12400         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12401         for (size_t s = 0; s < ret_var.datalen; s++) {
12402                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
12403                 int64_t ret_conv_18_ref = 0;
12404                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12405                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12406                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
12407                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
12408                 if (ret_conv_18_var.is_owned) {
12409                         ret_conv_18_ref |= 1;
12410                 }
12411                 ret_arr_ptr[s] = ret_conv_18_ref;
12412         }
12413         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12414         FREE(ret_var.data);
12415         return ret_arr;
12416 }
12417
12418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
12419         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12420         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12421         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12422         LDKPublicKey their_node_id_ref;
12423         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12424         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12425         LDKInit init_conv;
12426         init_conv.inner = (void*)(init & (~1));
12427         init_conv.is_owned = false;
12428         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
12429         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
12430 }
12431
12432 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) {
12433         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12434         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12435         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12436         LDKPublicKey their_node_id_ref;
12437         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12438         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12439         LDKReplyChannelRange msg_conv;
12440         msg_conv.inner = (void*)(msg & (~1));
12441         msg_conv.is_owned = (msg & 1) || (msg == 0);
12442         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12443         msg_conv = ReplyChannelRange_clone(&msg_conv);
12444         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12445         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12446         return (int64_t)ret_conv;
12447 }
12448
12449 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) {
12450         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12451         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12452         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12453         LDKPublicKey their_node_id_ref;
12454         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12455         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12456         LDKReplyShortChannelIdsEnd msg_conv;
12457         msg_conv.inner = (void*)(msg & (~1));
12458         msg_conv.is_owned = (msg & 1) || (msg == 0);
12459         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12460         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
12461         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12462         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12463         return (int64_t)ret_conv;
12464 }
12465
12466 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) {
12467         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12468         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12469         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12470         LDKPublicKey their_node_id_ref;
12471         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12472         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12473         LDKQueryChannelRange msg_conv;
12474         msg_conv.inner = (void*)(msg & (~1));
12475         msg_conv.is_owned = (msg & 1) || (msg == 0);
12476         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12477         msg_conv = QueryChannelRange_clone(&msg_conv);
12478         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12479         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12480         return (int64_t)ret_conv;
12481 }
12482
12483 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) {
12484         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12485         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12486         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12487         LDKPublicKey their_node_id_ref;
12488         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12489         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12490         LDKQueryShortChannelIds msg_conv;
12491         msg_conv.inner = (void*)(msg & (~1));
12492         msg_conv.is_owned = (msg & 1) || (msg == 0);
12493         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12494         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12495         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12496         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12497         return (int64_t)ret_conv;
12498 }
12499
12500 typedef struct LDKCustomMessageReader_JCalls {
12501         atomic_size_t refcnt;
12502         JavaVM *vm;
12503         jweak o;
12504         jmethodID read_meth;
12505 } LDKCustomMessageReader_JCalls;
12506 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
12507         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12508         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12509                 JNIEnv *env;
12510                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12511                 if (get_jenv_res == JNI_EDETACHED) {
12512                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12513                 } else {
12514                         DO_ASSERT(get_jenv_res == JNI_OK);
12515                 }
12516                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12517                 if (get_jenv_res == JNI_EDETACHED) {
12518                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12519                 }
12520                 FREE(j_calls);
12521         }
12522 }
12523 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
12524         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12525         JNIEnv *env;
12526         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12527         if (get_jenv_res == JNI_EDETACHED) {
12528                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12529         } else {
12530                 DO_ASSERT(get_jenv_res == JNI_OK);
12531         }
12532         int16_t message_type_conv = message_type;
12533         LDKu8slice buffer_var = buffer;
12534         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
12535         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
12536         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12537         CHECK(obj != NULL);
12538         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
12539         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12540                 (*env)->ExceptionDescribe(env);
12541                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
12542         }
12543         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12544         CHECK_ACCESS(ret_ptr);
12545         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
12546         FREE((void*)ret);
12547         if (get_jenv_res == JNI_EDETACHED) {
12548                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12549         }
12550         return ret_conv;
12551 }
12552 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
12553         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
12554         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12555 }
12556 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
12557         jclass c = (*env)->GetObjectClass(env, o);
12558         CHECK(c != NULL);
12559         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
12560         atomic_init(&calls->refcnt, 1);
12561         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12562         calls->o = (*env)->NewWeakGlobalRef(env, o);
12563         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
12564         CHECK(calls->read_meth != NULL);
12565
12566         LDKCustomMessageReader ret = {
12567                 .this_arg = (void*) calls,
12568                 .read = read_LDKCustomMessageReader_jcall,
12569                 .free = LDKCustomMessageReader_JCalls_free,
12570         };
12571         return ret;
12572 }
12573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
12574         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
12575         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
12576         return (uint64_t)res_ptr;
12577 }
12578 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) {
12579         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12580         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12581         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
12582         LDKu8slice buffer_ref;
12583         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
12584         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
12585         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12586         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
12587         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
12588         return (int64_t)ret_conv;
12589 }
12590
12591 typedef struct LDKCustomMessageHandler_JCalls {
12592         atomic_size_t refcnt;
12593         JavaVM *vm;
12594         jweak o;
12595         LDKCustomMessageReader_JCalls* CustomMessageReader;
12596         jmethodID handle_custom_message_meth;
12597         jmethodID get_and_clear_pending_msg_meth;
12598 } LDKCustomMessageHandler_JCalls;
12599 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
12600         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12601         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12602                 JNIEnv *env;
12603                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12604                 if (get_jenv_res == JNI_EDETACHED) {
12605                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12606                 } else {
12607                         DO_ASSERT(get_jenv_res == JNI_OK);
12608                 }
12609                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12610                 if (get_jenv_res == JNI_EDETACHED) {
12611                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12612                 }
12613                 FREE(j_calls);
12614         }
12615 }
12616 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
12617         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12618         JNIEnv *env;
12619         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12620         if (get_jenv_res == JNI_EDETACHED) {
12621                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12622         } else {
12623                 DO_ASSERT(get_jenv_res == JNI_OK);
12624         }
12625         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
12626         *msg_ret = msg;
12627         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
12628         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
12629         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12630         CHECK(obj != NULL);
12631         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
12632         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12633                 (*env)->ExceptionDescribe(env);
12634                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
12635         }
12636         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12637         CHECK_ACCESS(ret_ptr);
12638         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12639         FREE((void*)ret);
12640         if (get_jenv_res == JNI_EDETACHED) {
12641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12642         }
12643         return ret_conv;
12644 }
12645 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
12646         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12647         JNIEnv *env;
12648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12649         if (get_jenv_res == JNI_EDETACHED) {
12650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12651         } else {
12652                 DO_ASSERT(get_jenv_res == JNI_OK);
12653         }
12654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12655         CHECK(obj != NULL);
12656         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
12657         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12658                 (*env)->ExceptionDescribe(env);
12659                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
12660         }
12661         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
12662         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12663         if (ret_constr.datalen > 0)
12664                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
12665         else
12666                 ret_constr.data = NULL;
12667         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12668         for (size_t z = 0; z < ret_constr.datalen; z++) {
12669                 int64_t ret_conv_25 = ret_vals[z];
12670                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
12671                 CHECK_ACCESS(ret_conv_25_ptr);
12672                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
12673                 FREE((void*)ret_conv_25);
12674                 ret_constr.data[z] = ret_conv_25_conv;
12675         }
12676         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12677         if (get_jenv_res == JNI_EDETACHED) {
12678                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12679         }
12680         return ret_constr;
12681 }
12682 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
12683         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
12684         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12685         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
12686 }
12687 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12688         jclass c = (*env)->GetObjectClass(env, o);
12689         CHECK(c != NULL);
12690         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
12691         atomic_init(&calls->refcnt, 1);
12692         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12693         calls->o = (*env)->NewWeakGlobalRef(env, o);
12694         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
12695         CHECK(calls->handle_custom_message_meth != NULL);
12696         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
12697         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
12698
12699         LDKCustomMessageHandler ret = {
12700                 .this_arg = (void*) calls,
12701                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
12702                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
12703                 .free = LDKCustomMessageHandler_JCalls_free,
12704                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
12705         };
12706         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
12707         return ret;
12708 }
12709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12710         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
12711         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
12712         return (uint64_t)res_ptr;
12713 }
12714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
12715         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
12716         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
12717         DO_ASSERT((res_ptr & 1) == 0);
12718         return (int64_t)(res_ptr | 1);
12719 }
12720 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) {
12721         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12722         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12723         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12724         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
12725         CHECK_ACCESS(msg_ptr);
12726         LDKType msg_conv = *(LDKType*)(msg_ptr);
12727         if (msg_conv.free == LDKType_JCalls_free) {
12728                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12729                 LDKType_JCalls_cloned(&msg_conv);
12730         }
12731         LDKPublicKey sender_node_id_ref;
12732         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
12733         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
12734         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12735         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
12736         return (int64_t)ret_conv;
12737 }
12738
12739 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
12740         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12741         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12742         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12743         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
12744         int64_tArray ret_arr = NULL;
12745         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12746         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12747         for (size_t z = 0; z < ret_var.datalen; z++) {
12748                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
12749                 *ret_conv_25_conv = ret_var.data[z];
12750                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
12751         }
12752         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12753         FREE(ret_var.data);
12754         return ret_arr;
12755 }
12756
12757 typedef struct LDKSocketDescriptor_JCalls {
12758         atomic_size_t refcnt;
12759         JavaVM *vm;
12760         jweak o;
12761         jmethodID send_data_meth;
12762         jmethodID disconnect_socket_meth;
12763         jmethodID eq_meth;
12764         jmethodID hash_meth;
12765 } LDKSocketDescriptor_JCalls;
12766 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
12767         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12768         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12769                 JNIEnv *env;
12770                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12771                 if (get_jenv_res == JNI_EDETACHED) {
12772                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12773                 } else {
12774                         DO_ASSERT(get_jenv_res == JNI_OK);
12775                 }
12776                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12777                 if (get_jenv_res == JNI_EDETACHED) {
12778                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12779                 }
12780                 FREE(j_calls);
12781         }
12782 }
12783 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
12784         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12785         JNIEnv *env;
12786         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12787         if (get_jenv_res == JNI_EDETACHED) {
12788                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12789         } else {
12790                 DO_ASSERT(get_jenv_res == JNI_OK);
12791         }
12792         LDKu8slice data_var = data;
12793         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
12794         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
12795         jboolean resume_read_conv = resume_read;
12796         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12797         CHECK(obj != NULL);
12798         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
12799         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12800                 (*env)->ExceptionDescribe(env);
12801                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
12802         }
12803         if (get_jenv_res == JNI_EDETACHED) {
12804                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12805         }
12806         return ret;
12807 }
12808 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
12809         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12810         JNIEnv *env;
12811         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12812         if (get_jenv_res == JNI_EDETACHED) {
12813                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12814         } else {
12815                 DO_ASSERT(get_jenv_res == JNI_OK);
12816         }
12817         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12818         CHECK(obj != NULL);
12819         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
12820         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12821                 (*env)->ExceptionDescribe(env);
12822                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
12823         }
12824         if (get_jenv_res == JNI_EDETACHED) {
12825                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12826         }
12827 }
12828 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
12829         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12830         JNIEnv *env;
12831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12832         if (get_jenv_res == JNI_EDETACHED) {
12833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12834         } else {
12835                 DO_ASSERT(get_jenv_res == JNI_OK);
12836         }
12837         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12838         *other_arg_clone = SocketDescriptor_clone(other_arg);
12839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12840         CHECK(obj != NULL);
12841         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
12842         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12843                 (*env)->ExceptionDescribe(env);
12844                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
12845         }
12846         if (get_jenv_res == JNI_EDETACHED) {
12847                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12848         }
12849         return ret;
12850 }
12851 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
12852         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12853         JNIEnv *env;
12854         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12855         if (get_jenv_res == JNI_EDETACHED) {
12856                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12857         } else {
12858                 DO_ASSERT(get_jenv_res == JNI_OK);
12859         }
12860         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12861         CHECK(obj != NULL);
12862         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
12863         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12864                 (*env)->ExceptionDescribe(env);
12865                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
12866         }
12867         if (get_jenv_res == JNI_EDETACHED) {
12868                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12869         }
12870         return ret;
12871 }
12872 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
12873         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
12874         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12875 }
12876 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
12877         jclass c = (*env)->GetObjectClass(env, o);
12878         CHECK(c != NULL);
12879         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
12880         atomic_init(&calls->refcnt, 1);
12881         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12882         calls->o = (*env)->NewWeakGlobalRef(env, o);
12883         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
12884         CHECK(calls->send_data_meth != NULL);
12885         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
12886         CHECK(calls->disconnect_socket_meth != NULL);
12887         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
12888         CHECK(calls->eq_meth != NULL);
12889         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
12890         CHECK(calls->hash_meth != NULL);
12891
12892         LDKSocketDescriptor ret = {
12893                 .this_arg = (void*) calls,
12894                 .send_data = send_data_LDKSocketDescriptor_jcall,
12895                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12896                 .eq = eq_LDKSocketDescriptor_jcall,
12897                 .hash = hash_LDKSocketDescriptor_jcall,
12898                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12899                 .free = LDKSocketDescriptor_JCalls_free,
12900         };
12901         return ret;
12902 }
12903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12904         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12905         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12906         return (uint64_t)res_ptr;
12907 }
12908 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) {
12909         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12910         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12911         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12912         LDKu8slice data_ref;
12913         data_ref.datalen = (*env)->GetArrayLength(env, data);
12914         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12915         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12916         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12917         return ret_conv;
12918 }
12919
12920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12921         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12922         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12923         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12924         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12925 }
12926
12927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12928         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12929         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12930         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12931         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
12932         return ret_conv;
12933 }
12934
12935 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
12936 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
12937 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
12938 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
12939 static jclass LDKEffectiveCapacity_Total_class = NULL;
12940 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
12941 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
12942 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
12943 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
12944 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
12945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
12946         LDKEffectiveCapacity_ExactLiquidity_class =
12947                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
12948         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
12949         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
12950         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
12951         LDKEffectiveCapacity_MaximumHTLC_class =
12952                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
12953         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
12954         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
12955         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
12956         LDKEffectiveCapacity_Total_class =
12957                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
12958         CHECK(LDKEffectiveCapacity_Total_class != NULL);
12959         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
12960         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
12961         LDKEffectiveCapacity_Infinite_class =
12962                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
12963         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
12964         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
12965         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
12966         LDKEffectiveCapacity_Unknown_class =
12967                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
12968         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
12969         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
12970         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
12971 }
12972 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12973         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
12974         switch(obj->tag) {
12975                 case LDKEffectiveCapacity_ExactLiquidity: {
12976                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
12977                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
12978                 }
12979                 case LDKEffectiveCapacity_MaximumHTLC: {
12980                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
12981                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
12982                 }
12983                 case LDKEffectiveCapacity_Total: {
12984                         int64_t capacity_msat_conv = obj->total.capacity_msat;
12985                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv);
12986                 }
12987                 case LDKEffectiveCapacity_Infinite: {
12988                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
12989                 }
12990                 case LDKEffectiveCapacity_Unknown: {
12991                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
12992                 }
12993                 default: abort();
12994         }
12995 }
12996 typedef struct LDKScore_JCalls {
12997         atomic_size_t refcnt;
12998         JavaVM *vm;
12999         jweak o;
13000         jmethodID channel_penalty_msat_meth;
13001         jmethodID payment_path_failed_meth;
13002         jmethodID payment_path_successful_meth;
13003         jmethodID write_meth;
13004 } LDKScore_JCalls;
13005 static void LDKScore_JCalls_free(void* this_arg) {
13006         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13007         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13008                 JNIEnv *env;
13009                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13010                 if (get_jenv_res == JNI_EDETACHED) {
13011                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13012                 } else {
13013                         DO_ASSERT(get_jenv_res == JNI_OK);
13014                 }
13015                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13016                 if (get_jenv_res == JNI_EDETACHED) {
13017                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13018                 }
13019                 FREE(j_calls);
13020         }
13021 }
13022 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
13023         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13024         JNIEnv *env;
13025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13026         if (get_jenv_res == JNI_EDETACHED) {
13027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13028         } else {
13029                 DO_ASSERT(get_jenv_res == JNI_OK);
13030         }
13031         int64_t short_channel_id_conv = short_channel_id;
13032         int64_t send_amt_msat_conv = send_amt_msat;
13033         int64_t capacity_msat_conv = capacity_msat;
13034         LDKNodeId source_var = *source;
13035         int64_t source_ref = 0;
13036         source_var = NodeId_clone(&source_var);
13037         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13038         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13039         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
13040         source_ref = (uintptr_t)source_var.inner;
13041         if (source_var.is_owned) {
13042                 source_ref |= 1;
13043         }
13044         LDKNodeId target_var = *target;
13045         int64_t target_ref = 0;
13046         target_var = NodeId_clone(&target_var);
13047         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13048         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13049         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
13050         target_ref = (uintptr_t)target_var.inner;
13051         if (target_var.is_owned) {
13052                 target_ref |= 1;
13053         }
13054         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13055         CHECK(obj != NULL);
13056         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, send_amt_msat_conv, capacity_msat_conv, source_ref, target_ref);
13057         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13058                 (*env)->ExceptionDescribe(env);
13059                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
13060         }
13061         if (get_jenv_res == JNI_EDETACHED) {
13062                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13063         }
13064         return ret;
13065 }
13066 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
13067         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13068         JNIEnv *env;
13069         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13070         if (get_jenv_res == JNI_EDETACHED) {
13071                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13072         } else {
13073                 DO_ASSERT(get_jenv_res == JNI_OK);
13074         }
13075         LDKCVec_RouteHopZ path_var = path;
13076         int64_tArray path_arr = NULL;
13077         path_arr = (*env)->NewLongArray(env, path_var.datalen);
13078         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
13079         for (size_t k = 0; k < path_var.datalen; k++) {
13080                 LDKRouteHop path_conv_10_var = path_var.data[k];
13081                 int64_t path_conv_10_ref = 0;
13082                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13083                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13084                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
13085                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
13086                 if (path_conv_10_var.is_owned) {
13087                         path_conv_10_ref |= 1;
13088                 }
13089                 path_arr_ptr[k] = path_conv_10_ref;
13090         }
13091         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
13092         FREE(path_var.data);
13093         int64_t short_channel_id_conv = short_channel_id;
13094         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13095         CHECK(obj != NULL);
13096         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
13097         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13098                 (*env)->ExceptionDescribe(env);
13099                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
13100         }
13101         if (get_jenv_res == JNI_EDETACHED) {
13102                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13103         }
13104 }
13105 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
13106         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13107         JNIEnv *env;
13108         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13109         if (get_jenv_res == JNI_EDETACHED) {
13110                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13111         } else {
13112                 DO_ASSERT(get_jenv_res == JNI_OK);
13113         }
13114         LDKCVec_RouteHopZ path_var = path;
13115         int64_tArray path_arr = NULL;
13116         path_arr = (*env)->NewLongArray(env, path_var.datalen);
13117         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
13118         for (size_t k = 0; k < path_var.datalen; k++) {
13119                 LDKRouteHop path_conv_10_var = path_var.data[k];
13120                 int64_t path_conv_10_ref = 0;
13121                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13122                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13123                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
13124                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
13125                 if (path_conv_10_var.is_owned) {
13126                         path_conv_10_ref |= 1;
13127                 }
13128                 path_arr_ptr[k] = path_conv_10_ref;
13129         }
13130         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
13131         FREE(path_var.data);
13132         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13133         CHECK(obj != NULL);
13134         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
13135         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13136                 (*env)->ExceptionDescribe(env);
13137                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
13138         }
13139         if (get_jenv_res == JNI_EDETACHED) {
13140                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13141         }
13142 }
13143 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
13144         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13145         JNIEnv *env;
13146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13147         if (get_jenv_res == JNI_EDETACHED) {
13148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13149         } else {
13150                 DO_ASSERT(get_jenv_res == JNI_OK);
13151         }
13152         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13153         CHECK(obj != NULL);
13154         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
13155         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13156                 (*env)->ExceptionDescribe(env);
13157                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
13158         }
13159         LDKCVec_u8Z ret_ref;
13160         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
13161         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
13162         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
13163         if (get_jenv_res == JNI_EDETACHED) {
13164                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13165         }
13166         return ret_ref;
13167 }
13168 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
13169         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
13170         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13171 }
13172 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
13173         jclass c = (*env)->GetObjectClass(env, o);
13174         CHECK(c != NULL);
13175         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
13176         atomic_init(&calls->refcnt, 1);
13177         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13178         calls->o = (*env)->NewWeakGlobalRef(env, o);
13179         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
13180         CHECK(calls->channel_penalty_msat_meth != NULL);
13181         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
13182         CHECK(calls->payment_path_failed_meth != NULL);
13183         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
13184         CHECK(calls->payment_path_successful_meth != NULL);
13185         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
13186         CHECK(calls->write_meth != NULL);
13187
13188         LDKScore ret = {
13189                 .this_arg = (void*) calls,
13190                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
13191                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
13192                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
13193                 .write = write_LDKScore_jcall,
13194                 .free = LDKScore_JCalls_free,
13195         };
13196         return ret;
13197 }
13198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
13199         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
13200         *res_ptr = LDKScore_init(env, clz, o);
13201         return (uint64_t)res_ptr;
13202 }
13203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, int64_t source, int64_t target) {
13204         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13205         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13206         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13207         LDKNodeId source_conv;
13208         source_conv.inner = (void*)(source & (~1));
13209         source_conv.is_owned = false;
13210         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
13211         LDKNodeId target_conv;
13212         target_conv.inner = (void*)(target & (~1));
13213         target_conv.is_owned = false;
13214         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
13215         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
13216         return ret_conv;
13217 }
13218
13219 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) {
13220         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13222         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13223         LDKCVec_RouteHopZ path_constr;
13224         path_constr.datalen = (*env)->GetArrayLength(env, path);
13225         if (path_constr.datalen > 0)
13226                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13227         else
13228                 path_constr.data = NULL;
13229         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
13230         for (size_t k = 0; k < path_constr.datalen; k++) {
13231                 int64_t path_conv_10 = path_vals[k];
13232                 LDKRouteHop path_conv_10_conv;
13233                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
13234                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
13235                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
13236                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
13237                 path_constr.data[k] = path_conv_10_conv;
13238         }
13239         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
13240         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
13241 }
13242
13243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
13244         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13245         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13246         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13247         LDKCVec_RouteHopZ path_constr;
13248         path_constr.datalen = (*env)->GetArrayLength(env, path);
13249         if (path_constr.datalen > 0)
13250                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13251         else
13252                 path_constr.data = NULL;
13253         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
13254         for (size_t k = 0; k < path_constr.datalen; k++) {
13255                 int64_t path_conv_10 = path_vals[k];
13256                 LDKRouteHop path_conv_10_conv;
13257                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
13258                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
13259                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
13260                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
13261                 path_constr.data[k] = path_conv_10_conv;
13262         }
13263         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
13264         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
13265 }
13266
13267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
13268         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13269         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13270         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13271         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
13272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13274         CVec_u8Z_free(ret_var);
13275         return ret_arr;
13276 }
13277
13278 typedef struct LDKLockableScore_JCalls {
13279         atomic_size_t refcnt;
13280         JavaVM *vm;
13281         jweak o;
13282         jmethodID lock_meth;
13283 } LDKLockableScore_JCalls;
13284 static void LDKLockableScore_JCalls_free(void* this_arg) {
13285         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13286         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13287                 JNIEnv *env;
13288                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13289                 if (get_jenv_res == JNI_EDETACHED) {
13290                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13291                 } else {
13292                         DO_ASSERT(get_jenv_res == JNI_OK);
13293                 }
13294                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13295                 if (get_jenv_res == JNI_EDETACHED) {
13296                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13297                 }
13298                 FREE(j_calls);
13299         }
13300 }
13301 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
13302         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13303         JNIEnv *env;
13304         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13305         if (get_jenv_res == JNI_EDETACHED) {
13306                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13307         } else {
13308                 DO_ASSERT(get_jenv_res == JNI_OK);
13309         }
13310         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13311         CHECK(obj != NULL);
13312         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
13313         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13314                 (*env)->ExceptionDescribe(env);
13315                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
13316         }
13317         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13318         CHECK_ACCESS(ret_ptr);
13319         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
13320         if (ret_conv.free == LDKScore_JCalls_free) {
13321                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13322                 LDKScore_JCalls_cloned(&ret_conv);
13323         }// WARNING: we may need a move here but no clone is available for LDKScore
13324         
13325         if (get_jenv_res == JNI_EDETACHED) {
13326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13327         }
13328         return ret_conv;
13329 }
13330 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
13331         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
13332         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13333 }
13334 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
13335         jclass c = (*env)->GetObjectClass(env, o);
13336         CHECK(c != NULL);
13337         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
13338         atomic_init(&calls->refcnt, 1);
13339         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13340         calls->o = (*env)->NewWeakGlobalRef(env, o);
13341         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
13342         CHECK(calls->lock_meth != NULL);
13343
13344         LDKLockableScore ret = {
13345                 .this_arg = (void*) calls,
13346                 .lock = lock_LDKLockableScore_jcall,
13347                 .free = LDKLockableScore_JCalls_free,
13348         };
13349         return ret;
13350 }
13351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
13352         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
13353         *res_ptr = LDKLockableScore_init(env, clz, o);
13354         return (uint64_t)res_ptr;
13355 }
13356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13357         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13358         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13359         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13360         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13361         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13362         return (int64_t)ret_ret;
13363 }
13364
13365 typedef struct LDKPersister_JCalls {
13366         atomic_size_t refcnt;
13367         JavaVM *vm;
13368         jweak o;
13369         jmethodID persist_manager_meth;
13370         jmethodID persist_graph_meth;
13371 } LDKPersister_JCalls;
13372 static void LDKPersister_JCalls_free(void* this_arg) {
13373         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13374         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13375                 JNIEnv *env;
13376                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13377                 if (get_jenv_res == JNI_EDETACHED) {
13378                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13379                 } else {
13380                         DO_ASSERT(get_jenv_res == JNI_OK);
13381                 }
13382                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13383                 if (get_jenv_res == JNI_EDETACHED) {
13384                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13385                 }
13386                 FREE(j_calls);
13387         }
13388 }
13389 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
13390         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13391         JNIEnv *env;
13392         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13393         if (get_jenv_res == JNI_EDETACHED) {
13394                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13395         } else {
13396                 DO_ASSERT(get_jenv_res == JNI_OK);
13397         }
13398         LDKChannelManager channel_manager_var = *channel_manager;
13399         int64_t channel_manager_ref = 0;
13400         // WARNING: we may need a move here but no clone is available for LDKChannelManager
13401         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13402         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13403         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
13404         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
13405         if (channel_manager_var.is_owned) {
13406                 channel_manager_ref |= 1;
13407         }
13408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13409         CHECK(obj != NULL);
13410         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
13411         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13412                 (*env)->ExceptionDescribe(env);
13413                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
13414         }
13415         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13416         CHECK_ACCESS(ret_ptr);
13417         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13418         FREE((void*)ret);
13419         if (get_jenv_res == JNI_EDETACHED) {
13420                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13421         }
13422         return ret_conv;
13423 }
13424 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
13425         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13426         JNIEnv *env;
13427         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13428         if (get_jenv_res == JNI_EDETACHED) {
13429                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13430         } else {
13431                 DO_ASSERT(get_jenv_res == JNI_OK);
13432         }
13433         LDKNetworkGraph network_graph_var = *network_graph;
13434         int64_t network_graph_ref = 0;
13435         network_graph_var = NetworkGraph_clone(&network_graph_var);
13436         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13437         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13438         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
13439         network_graph_ref = (uintptr_t)network_graph_var.inner;
13440         if (network_graph_var.is_owned) {
13441                 network_graph_ref |= 1;
13442         }
13443         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13444         CHECK(obj != NULL);
13445         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
13446         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13447                 (*env)->ExceptionDescribe(env);
13448                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
13449         }
13450         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13451         CHECK_ACCESS(ret_ptr);
13452         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13453         FREE((void*)ret);
13454         if (get_jenv_res == JNI_EDETACHED) {
13455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13456         }
13457         return ret_conv;
13458 }
13459 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
13460         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
13461         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13462 }
13463 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
13464         jclass c = (*env)->GetObjectClass(env, o);
13465         CHECK(c != NULL);
13466         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
13467         atomic_init(&calls->refcnt, 1);
13468         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13469         calls->o = (*env)->NewWeakGlobalRef(env, o);
13470         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
13471         CHECK(calls->persist_manager_meth != NULL);
13472         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
13473         CHECK(calls->persist_graph_meth != NULL);
13474
13475         LDKPersister ret = {
13476                 .this_arg = (void*) calls,
13477                 .persist_manager = persist_manager_LDKPersister_jcall,
13478                 .persist_graph = persist_graph_LDKPersister_jcall,
13479                 .free = LDKPersister_JCalls_free,
13480         };
13481         return ret;
13482 }
13483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
13484         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
13485         *res_ptr = LDKPersister_init(env, clz, o);
13486         return (uint64_t)res_ptr;
13487 }
13488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
13489         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13490         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13491         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
13492         LDKChannelManager channel_manager_conv;
13493         channel_manager_conv.inner = (void*)(channel_manager & (~1));
13494         channel_manager_conv.is_owned = false;
13495         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
13496         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13497         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
13498         return (int64_t)ret_conv;
13499 }
13500
13501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
13502         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13503         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13504         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
13505         LDKNetworkGraph network_graph_conv;
13506         network_graph_conv.inner = (void*)(network_graph & (~1));
13507         network_graph_conv.is_owned = false;
13508         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
13509         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13510         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
13511         return (int64_t)ret_conv;
13512 }
13513
13514 static jclass LDKFallback_SegWitProgram_class = NULL;
13515 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13516 static jclass LDKFallback_PubKeyHash_class = NULL;
13517 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13518 static jclass LDKFallback_ScriptHash_class = NULL;
13519 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13521         LDKFallback_SegWitProgram_class =
13522                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13523         CHECK(LDKFallback_SegWitProgram_class != NULL);
13524         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13525         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13526         LDKFallback_PubKeyHash_class =
13527                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13528         CHECK(LDKFallback_PubKeyHash_class != NULL);
13529         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13530         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13531         LDKFallback_ScriptHash_class =
13532                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13533         CHECK(LDKFallback_ScriptHash_class != NULL);
13534         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13535         CHECK(LDKFallback_ScriptHash_meth != NULL);
13536 }
13537 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13538         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13539         switch(obj->tag) {
13540                 case LDKFallback_SegWitProgram: {
13541                         uint8_t version_val = obj->seg_wit_program.version._0;
13542                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13543                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13544                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13545                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13546                 }
13547                 case LDKFallback_PubKeyHash: {
13548                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13549                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13550                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13551                 }
13552                 case LDKFallback_ScriptHash: {
13553                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13554                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13555                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13556                 }
13557                 default: abort();
13558         }
13559 }
13560 typedef struct LDKPayer_JCalls {
13561         atomic_size_t refcnt;
13562         JavaVM *vm;
13563         jweak o;
13564         jmethodID node_id_meth;
13565         jmethodID first_hops_meth;
13566         jmethodID send_payment_meth;
13567         jmethodID send_spontaneous_payment_meth;
13568         jmethodID retry_payment_meth;
13569         jmethodID abandon_payment_meth;
13570 } LDKPayer_JCalls;
13571 static void LDKPayer_JCalls_free(void* this_arg) {
13572         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13573         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13574                 JNIEnv *env;
13575                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13576                 if (get_jenv_res == JNI_EDETACHED) {
13577                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13578                 } else {
13579                         DO_ASSERT(get_jenv_res == JNI_OK);
13580                 }
13581                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13582                 if (get_jenv_res == JNI_EDETACHED) {
13583                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13584                 }
13585                 FREE(j_calls);
13586         }
13587 }
13588 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13589         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13590         JNIEnv *env;
13591         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13592         if (get_jenv_res == JNI_EDETACHED) {
13593                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13594         } else {
13595                 DO_ASSERT(get_jenv_res == JNI_OK);
13596         }
13597         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13598         CHECK(obj != NULL);
13599         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13600         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13601                 (*env)->ExceptionDescribe(env);
13602                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13603         }
13604         LDKPublicKey ret_ref;
13605         CHECK((*env)->GetArrayLength(env, ret) == 33);
13606         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13607         if (get_jenv_res == JNI_EDETACHED) {
13608                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13609         }
13610         return ret_ref;
13611 }
13612 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13613         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13614         JNIEnv *env;
13615         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13616         if (get_jenv_res == JNI_EDETACHED) {
13617                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13618         } else {
13619                 DO_ASSERT(get_jenv_res == JNI_OK);
13620         }
13621         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13622         CHECK(obj != NULL);
13623         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13624         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13625                 (*env)->ExceptionDescribe(env);
13626                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13627         }
13628         LDKCVec_ChannelDetailsZ ret_constr;
13629         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13630         if (ret_constr.datalen > 0)
13631                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13632         else
13633                 ret_constr.data = NULL;
13634         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13635         for (size_t q = 0; q < ret_constr.datalen; q++) {
13636                 int64_t ret_conv_16 = ret_vals[q];
13637                 LDKChannelDetails ret_conv_16_conv;
13638                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
13639                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
13640                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13641                 ret_constr.data[q] = ret_conv_16_conv;
13642         }
13643         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13644         if (get_jenv_res == JNI_EDETACHED) {
13645                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13646         }
13647         return ret_constr;
13648 }
13649 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13650         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13651         JNIEnv *env;
13652         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13653         if (get_jenv_res == JNI_EDETACHED) {
13654                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13655         } else {
13656                 DO_ASSERT(get_jenv_res == JNI_OK);
13657         }
13658         LDKRoute route_var = *route;
13659         int64_t route_ref = 0;
13660         route_var = Route_clone(&route_var);
13661         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13662         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13663         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13664         route_ref = (uintptr_t)route_var.inner;
13665         if (route_var.is_owned) {
13666                 route_ref |= 1;
13667         }
13668         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13669         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13670         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13671         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13673         CHECK(obj != NULL);
13674         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13675         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13676                 (*env)->ExceptionDescribe(env);
13677                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13678         }
13679         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13680         CHECK_ACCESS(ret_ptr);
13681         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13682         FREE((void*)ret);
13683         if (get_jenv_res == JNI_EDETACHED) {
13684                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13685         }
13686         return ret_conv;
13687 }
13688 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13689         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13690         JNIEnv *env;
13691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13692         if (get_jenv_res == JNI_EDETACHED) {
13693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13694         } else {
13695                 DO_ASSERT(get_jenv_res == JNI_OK);
13696         }
13697         LDKRoute route_var = *route;
13698         int64_t route_ref = 0;
13699         route_var = Route_clone(&route_var);
13700         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13701         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13702         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13703         route_ref = (uintptr_t)route_var.inner;
13704         if (route_var.is_owned) {
13705                 route_ref |= 1;
13706         }
13707         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13708         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13709         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13710         CHECK(obj != NULL);
13711         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13712         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13713                 (*env)->ExceptionDescribe(env);
13714                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13715         }
13716         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13717         CHECK_ACCESS(ret_ptr);
13718         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13719         FREE((void*)ret);
13720         if (get_jenv_res == JNI_EDETACHED) {
13721                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13722         }
13723         return ret_conv;
13724 }
13725 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13726         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13727         JNIEnv *env;
13728         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13729         if (get_jenv_res == JNI_EDETACHED) {
13730                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13731         } else {
13732                 DO_ASSERT(get_jenv_res == JNI_OK);
13733         }
13734         LDKRoute route_var = *route;
13735         int64_t route_ref = 0;
13736         route_var = Route_clone(&route_var);
13737         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13738         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13739         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13740         route_ref = (uintptr_t)route_var.inner;
13741         if (route_var.is_owned) {
13742                 route_ref |= 1;
13743         }
13744         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13745         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13746         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13747         CHECK(obj != NULL);
13748         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
13749         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13750                 (*env)->ExceptionDescribe(env);
13751                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
13752         }
13753         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13754         CHECK_ACCESS(ret_ptr);
13755         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
13756         FREE((void*)ret);
13757         if (get_jenv_res == JNI_EDETACHED) {
13758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13759         }
13760         return ret_conv;
13761 }
13762 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
13763         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13764         JNIEnv *env;
13765         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13766         if (get_jenv_res == JNI_EDETACHED) {
13767                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13768         } else {
13769                 DO_ASSERT(get_jenv_res == JNI_OK);
13770         }
13771         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13772         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13773         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13774         CHECK(obj != NULL);
13775         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
13776         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13777                 (*env)->ExceptionDescribe(env);
13778                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
13779         }
13780         if (get_jenv_res == JNI_EDETACHED) {
13781                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13782         }
13783 }
13784 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
13785         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
13786         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13787 }
13788 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
13789         jclass c = (*env)->GetObjectClass(env, o);
13790         CHECK(c != NULL);
13791         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
13792         atomic_init(&calls->refcnt, 1);
13793         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13794         calls->o = (*env)->NewWeakGlobalRef(env, o);
13795         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
13796         CHECK(calls->node_id_meth != NULL);
13797         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
13798         CHECK(calls->first_hops_meth != NULL);
13799         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
13800         CHECK(calls->send_payment_meth != NULL);
13801         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
13802         CHECK(calls->send_spontaneous_payment_meth != NULL);
13803         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
13804         CHECK(calls->retry_payment_meth != NULL);
13805         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
13806         CHECK(calls->abandon_payment_meth != NULL);
13807
13808         LDKPayer ret = {
13809                 .this_arg = (void*) calls,
13810                 .node_id = node_id_LDKPayer_jcall,
13811                 .first_hops = first_hops_LDKPayer_jcall,
13812                 .send_payment = send_payment_LDKPayer_jcall,
13813                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
13814                 .retry_payment = retry_payment_LDKPayer_jcall,
13815                 .abandon_payment = abandon_payment_LDKPayer_jcall,
13816                 .free = LDKPayer_JCalls_free,
13817         };
13818         return ret;
13819 }
13820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
13821         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
13822         *res_ptr = LDKPayer_init(env, clz, o);
13823         return (uint64_t)res_ptr;
13824 }
13825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13826         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13827         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13828         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13829         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
13831         return ret_arr;
13832 }
13833
13834 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
13835         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13836         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13837         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13838         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
13839         int64_tArray ret_arr = NULL;
13840         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13841         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13842         for (size_t q = 0; q < ret_var.datalen; q++) {
13843                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13844                 int64_t ret_conv_16_ref = 0;
13845                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13846                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13847                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
13848                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
13849                 if (ret_conv_16_var.is_owned) {
13850                         ret_conv_16_ref |= 1;
13851                 }
13852                 ret_arr_ptr[q] = ret_conv_16_ref;
13853         }
13854         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13855         FREE(ret_var.data);
13856         return ret_arr;
13857 }
13858
13859 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) {
13860         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13861         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13862         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13863         LDKRoute route_conv;
13864         route_conv.inner = (void*)(route & (~1));
13865         route_conv.is_owned = false;
13866         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13867         LDKThirtyTwoBytes payment_hash_ref;
13868         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13869         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13870         LDKThirtyTwoBytes payment_secret_ref;
13871         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13872         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13873         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13874         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
13875         return (int64_t)ret_conv;
13876 }
13877
13878 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) {
13879         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13880         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13881         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13882         LDKRoute route_conv;
13883         route_conv.inner = (void*)(route & (~1));
13884         route_conv.is_owned = false;
13885         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13886         LDKThirtyTwoBytes payment_preimage_ref;
13887         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13888         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13889         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13890         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
13891         return (int64_t)ret_conv;
13892 }
13893
13894 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) {
13895         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13896         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13897         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13898         LDKRoute route_conv;
13899         route_conv.inner = (void*)(route & (~1));
13900         route_conv.is_owned = false;
13901         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13902         LDKThirtyTwoBytes payment_id_ref;
13903         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13904         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13905         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13906         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
13907         return (int64_t)ret_conv;
13908 }
13909
13910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
13911         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13912         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13913         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13914         LDKThirtyTwoBytes payment_id_ref;
13915         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13916         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13917         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
13918 }
13919
13920 typedef struct LDKRouter_JCalls {
13921         atomic_size_t refcnt;
13922         JavaVM *vm;
13923         jweak o;
13924         jmethodID find_route_meth;
13925 } LDKRouter_JCalls;
13926 static void LDKRouter_JCalls_free(void* this_arg) {
13927         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13928         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13929                 JNIEnv *env;
13930                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13931                 if (get_jenv_res == JNI_EDETACHED) {
13932                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13933                 } else {
13934                         DO_ASSERT(get_jenv_res == JNI_OK);
13935                 }
13936                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13937                 if (get_jenv_res == JNI_EDETACHED) {
13938                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13939                 }
13940                 FREE(j_calls);
13941         }
13942 }
13943 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
13944         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13945         JNIEnv *env;
13946         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13947         if (get_jenv_res == JNI_EDETACHED) {
13948                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13949         } else {
13950                 DO_ASSERT(get_jenv_res == JNI_OK);
13951         }
13952         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
13953         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
13954         LDKRouteParameters route_params_var = *route_params;
13955         int64_t route_params_ref = 0;
13956         route_params_var = RouteParameters_clone(&route_params_var);
13957         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13958         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13959         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
13960         route_params_ref = (uintptr_t)route_params_var.inner;
13961         if (route_params_var.is_owned) {
13962                 route_params_ref |= 1;
13963         }
13964         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13965         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
13966         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
13967         int64_tArray first_hops_arr = NULL;
13968         if (first_hops != NULL) {
13969                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
13970                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
13971                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
13972                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
13973                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
13974                         int64_t first_hops_conv_16_ref = 0;
13975                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13976                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13977                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
13978                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
13979                         if (first_hops_conv_16_var.is_owned) {
13980                                 first_hops_conv_16_ref |= 1;
13981                         }
13982                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
13983                 }
13984                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
13985         }
13986         // WARNING: This object doesn't live past this scope, needs clone!
13987         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
13988         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13989         CHECK(obj != NULL);
13990         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, payment_hash_arr, first_hops_arr, ret_scorer);
13991         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13992                 (*env)->ExceptionDescribe(env);
13993                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
13994         }
13995         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13996         CHECK_ACCESS(ret_ptr);
13997         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
13998         FREE((void*)ret);
13999         if (get_jenv_res == JNI_EDETACHED) {
14000                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14001         }
14002         return ret_conv;
14003 }
14004 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14005         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14006         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14007 }
14008 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14009         jclass c = (*env)->GetObjectClass(env, o);
14010         CHECK(c != NULL);
14011         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14012         atomic_init(&calls->refcnt, 1);
14013         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14014         calls->o = (*env)->NewWeakGlobalRef(env, o);
14015         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14016         CHECK(calls->find_route_meth != NULL);
14017
14018         LDKRouter ret = {
14019                 .this_arg = (void*) calls,
14020                 .find_route = find_route_LDKRouter_jcall,
14021                 .free = LDKRouter_JCalls_free,
14022         };
14023         return ret;
14024 }
14025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14026         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14027         *res_ptr = LDKRouter_init(env, clz, o);
14028         return (uint64_t)res_ptr;
14029 }
14030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t route_params, int8_tArray payment_hash, int64_tArray first_hops, int64_t scorer) {
14031         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14032         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14033         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14034         LDKPublicKey payer_ref;
14035         CHECK((*env)->GetArrayLength(env, payer) == 33);
14036         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14037         LDKRouteParameters route_params_conv;
14038         route_params_conv.inner = (void*)(route_params & (~1));
14039         route_params_conv.is_owned = false;
14040         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14041         unsigned char payment_hash_arr[32];
14042         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14043         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14044         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14045         LDKCVec_ChannelDetailsZ first_hops_constr;
14046         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14047         if (first_hops != NULL) {
14048                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14049                 if (first_hops_constr.datalen > 0)
14050                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14051                 else
14052                         first_hops_constr.data = NULL;
14053                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14054                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14055                         int64_t first_hops_conv_16 = first_hops_vals[q];
14056                         LDKChannelDetails first_hops_conv_16_conv;
14057                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14058                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14059                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14060                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14061                 }
14062                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14063                 first_hops_ptr = &first_hops_constr;
14064         }
14065         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14066         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14067         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14068         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14069         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
14070         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14071         return (int64_t)ret_conv;
14072 }
14073
14074 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14075         LDKStr ret_str = _ldk_get_compiled_version();
14076         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14077         Str_free(ret_str);
14078         return ret_conv;
14079 }
14080
14081 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14082         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14083         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14084         Str_free(ret_str);
14085         return ret_conv;
14086 }
14087
14088 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14089         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14090         *ret_copy = Bech32Error_clone(arg);
14091 int64_t ret_ref = (uintptr_t)ret_copy;
14092         return ret_ref;
14093 }
14094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14095         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14096         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14097         return ret_conv;
14098 }
14099
14100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14101         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14102         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14103         *ret_copy = Bech32Error_clone(orig_conv);
14104         int64_t ret_ref = (uintptr_t)ret_copy;
14105         return ret_ref;
14106 }
14107
14108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14109         if ((o & 1) != 0) return;
14110         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14111         CHECK_ACCESS(o_ptr);
14112         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14113         FREE((void*)o);
14114         Bech32Error_free(o_conv);
14115 }
14116
14117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14118         LDKTransaction _res_ref;
14119         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14120         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14121         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14122         _res_ref.data_is_owned = true;
14123         Transaction_free(_res_ref);
14124 }
14125
14126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14127         LDKCVec_u8Z script_pubkey_ref;
14128         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14129         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14130         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14131         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14132         *ret_ref = TxOut_new(script_pubkey_ref, value);
14133         return (int64_t)ret_ref;
14134 }
14135
14136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14137         if ((_res & 1) != 0) return;
14138         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14139         CHECK_ACCESS(_res_ptr);
14140         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14141         FREE((void*)_res);
14142         TxOut_free(_res_conv);
14143 }
14144
14145 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14146         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14147         *ret_ref = TxOut_clone(arg);
14148         return (int64_t)ret_ref;
14149 }
14150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14151         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14152         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14153         return ret_conv;
14154 }
14155
14156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14157         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14158         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14159         *ret_ref = TxOut_clone(orig_conv);
14160         return (int64_t)ret_ref;
14161 }
14162
14163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14164         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14165         Str_free(dummy);
14166 }
14167
14168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14169         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14170         *ret_conv = CResult_NoneNoneZ_ok();
14171         return (int64_t)ret_conv;
14172 }
14173
14174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14175         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14176         *ret_conv = CResult_NoneNoneZ_err();
14177         return (int64_t)ret_conv;
14178 }
14179
14180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14181         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14182         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14183         return ret_conv;
14184 }
14185
14186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14187         if ((_res & 1) != 0) return;
14188         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14189         CHECK_ACCESS(_res_ptr);
14190         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14191         FREE((void*)_res);
14192         CResult_NoneNoneZ_free(_res_conv);
14193 }
14194
14195 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14196         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14197         *ret_conv = CResult_NoneNoneZ_clone(arg);
14198         return (int64_t)ret_conv;
14199 }
14200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14201         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14202         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14203         return ret_conv;
14204 }
14205
14206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14207         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14208         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14209         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14210         return (int64_t)ret_conv;
14211 }
14212
14213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14214         LDKCounterpartyCommitmentSecrets o_conv;
14215         o_conv.inner = (void*)(o & (~1));
14216         o_conv.is_owned = (o & 1) || (o == 0);
14217         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14218         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14219         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14220         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14221         return (int64_t)ret_conv;
14222 }
14223
14224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14225         LDKDecodeError e_conv;
14226         e_conv.inner = (void*)(e & (~1));
14227         e_conv.is_owned = (e & 1) || (e == 0);
14228         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14229         e_conv = DecodeError_clone(&e_conv);
14230         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14231         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14232         return (int64_t)ret_conv;
14233 }
14234
14235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14236         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14237         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14238         return ret_conv;
14239 }
14240
14241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14242         if ((_res & 1) != 0) return;
14243         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14244         CHECK_ACCESS(_res_ptr);
14245         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14246         FREE((void*)_res);
14247         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14248 }
14249
14250 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14251         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14252         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14253         return (int64_t)ret_conv;
14254 }
14255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14256         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14257         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14258         return ret_conv;
14259 }
14260
14261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14262         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14263         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14264         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
14265         return (int64_t)ret_conv;
14266 }
14267
14268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14269         LDKSecretKey o_ref;
14270         CHECK((*env)->GetArrayLength(env, o) == 32);
14271         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
14272         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14273         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
14274         return (int64_t)ret_conv;
14275 }
14276
14277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14278         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14279         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14280         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
14281         return (int64_t)ret_conv;
14282 }
14283
14284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14285         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
14286         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
14287         return ret_conv;
14288 }
14289
14290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14291         if ((_res & 1) != 0) return;
14292         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14293         CHECK_ACCESS(_res_ptr);
14294         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
14295         FREE((void*)_res);
14296         CResult_SecretKeyErrorZ_free(_res_conv);
14297 }
14298
14299 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
14300         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14301         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
14302         return (int64_t)ret_conv;
14303 }
14304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14305         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
14306         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
14307         return ret_conv;
14308 }
14309
14310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14311         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
14312         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14313         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
14314         return (int64_t)ret_conv;
14315 }
14316
14317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14318         LDKPublicKey o_ref;
14319         CHECK((*env)->GetArrayLength(env, o) == 33);
14320         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
14321         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14322         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
14323         return (int64_t)ret_conv;
14324 }
14325
14326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14327         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14328         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14329         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
14330         return (int64_t)ret_conv;
14331 }
14332
14333 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14334         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
14335         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
14336         return ret_conv;
14337 }
14338
14339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14340         if ((_res & 1) != 0) return;
14341         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14342         CHECK_ACCESS(_res_ptr);
14343         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
14344         FREE((void*)_res);
14345         CResult_PublicKeyErrorZ_free(_res_conv);
14346 }
14347
14348 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
14349         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14350         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
14351         return (int64_t)ret_conv;
14352 }
14353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14354         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
14355         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
14356         return ret_conv;
14357 }
14358
14359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14360         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
14361         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14362         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
14363         return (int64_t)ret_conv;
14364 }
14365
14366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14367         LDKTxCreationKeys o_conv;
14368         o_conv.inner = (void*)(o & (~1));
14369         o_conv.is_owned = (o & 1) || (o == 0);
14370         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14371         o_conv = TxCreationKeys_clone(&o_conv);
14372         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14373         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
14374         return (int64_t)ret_conv;
14375 }
14376
14377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14378         LDKDecodeError e_conv;
14379         e_conv.inner = (void*)(e & (~1));
14380         e_conv.is_owned = (e & 1) || (e == 0);
14381         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14382         e_conv = DecodeError_clone(&e_conv);
14383         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14384         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
14385         return (int64_t)ret_conv;
14386 }
14387
14388 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14389         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
14390         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
14391         return ret_conv;
14392 }
14393
14394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14395         if ((_res & 1) != 0) return;
14396         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14397         CHECK_ACCESS(_res_ptr);
14398         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
14399         FREE((void*)_res);
14400         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
14401 }
14402
14403 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
14404         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14405         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
14406         return (int64_t)ret_conv;
14407 }
14408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14409         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
14410         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
14411         return ret_conv;
14412 }
14413
14414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14415         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
14416         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14417         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
14418         return (int64_t)ret_conv;
14419 }
14420
14421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14422         LDKChannelPublicKeys o_conv;
14423         o_conv.inner = (void*)(o & (~1));
14424         o_conv.is_owned = (o & 1) || (o == 0);
14425         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14426         o_conv = ChannelPublicKeys_clone(&o_conv);
14427         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14428         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
14429         return (int64_t)ret_conv;
14430 }
14431
14432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14433         LDKDecodeError e_conv;
14434         e_conv.inner = (void*)(e & (~1));
14435         e_conv.is_owned = (e & 1) || (e == 0);
14436         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14437         e_conv = DecodeError_clone(&e_conv);
14438         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14439         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14440         return (int64_t)ret_conv;
14441 }
14442
14443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14444         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14445         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14446         return ret_conv;
14447 }
14448
14449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14450         if ((_res & 1) != 0) return;
14451         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14452         CHECK_ACCESS(_res_ptr);
14453         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14454         FREE((void*)_res);
14455         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14456 }
14457
14458 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14459         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14460         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14461         return (int64_t)ret_conv;
14462 }
14463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14464         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14465         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14466         return ret_conv;
14467 }
14468
14469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14470         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14471         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14472         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14473         return (int64_t)ret_conv;
14474 }
14475
14476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14477         LDKTxCreationKeys o_conv;
14478         o_conv.inner = (void*)(o & (~1));
14479         o_conv.is_owned = (o & 1) || (o == 0);
14480         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14481         o_conv = TxCreationKeys_clone(&o_conv);
14482         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14483         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14484         return (int64_t)ret_conv;
14485 }
14486
14487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14488         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14489         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14490         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14491         return (int64_t)ret_conv;
14492 }
14493
14494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14495         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14496         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14497         return ret_conv;
14498 }
14499
14500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14501         if ((_res & 1) != 0) return;
14502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14503         CHECK_ACCESS(_res_ptr);
14504         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14505         FREE((void*)_res);
14506         CResult_TxCreationKeysErrorZ_free(_res_conv);
14507 }
14508
14509 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14510         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14511         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14512         return (int64_t)ret_conv;
14513 }
14514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14515         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14516         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14517         return ret_conv;
14518 }
14519
14520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14521         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14522         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14523         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14524         return (int64_t)ret_conv;
14525 }
14526
14527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14528         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14529         *ret_copy = COption_u32Z_some(o);
14530         int64_t ret_ref = (uintptr_t)ret_copy;
14531         return ret_ref;
14532 }
14533
14534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14535         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14536         *ret_copy = COption_u32Z_none();
14537         int64_t ret_ref = (uintptr_t)ret_copy;
14538         return ret_ref;
14539 }
14540
14541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14542         if ((_res & 1) != 0) return;
14543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14544         CHECK_ACCESS(_res_ptr);
14545         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14546         FREE((void*)_res);
14547         COption_u32Z_free(_res_conv);
14548 }
14549
14550 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14551         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14552         *ret_copy = COption_u32Z_clone(arg);
14553 int64_t ret_ref = (uintptr_t)ret_copy;
14554         return ret_ref;
14555 }
14556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14557         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14558         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
14559         return ret_conv;
14560 }
14561
14562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14563         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14564         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14565         *ret_copy = COption_u32Z_clone(orig_conv);
14566         int64_t ret_ref = (uintptr_t)ret_copy;
14567         return ret_ref;
14568 }
14569
14570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14571         LDKHTLCOutputInCommitment o_conv;
14572         o_conv.inner = (void*)(o & (~1));
14573         o_conv.is_owned = (o & 1) || (o == 0);
14574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14575         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14576         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14577         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14578         return (int64_t)ret_conv;
14579 }
14580
14581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14582         LDKDecodeError e_conv;
14583         e_conv.inner = (void*)(e & (~1));
14584         e_conv.is_owned = (e & 1) || (e == 0);
14585         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14586         e_conv = DecodeError_clone(&e_conv);
14587         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14588         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14589         return (int64_t)ret_conv;
14590 }
14591
14592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14593         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14594         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14595         return ret_conv;
14596 }
14597
14598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14599         if ((_res & 1) != 0) return;
14600         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14601         CHECK_ACCESS(_res_ptr);
14602         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14603         FREE((void*)_res);
14604         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14605 }
14606
14607 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14608         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14609         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14610         return (int64_t)ret_conv;
14611 }
14612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14613         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
14614         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14615         return ret_conv;
14616 }
14617
14618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14619         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
14620         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14621         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14622         return (int64_t)ret_conv;
14623 }
14624
14625 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14626         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14627         return ret_conv;
14628 }
14629
14630 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14631         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14632         return ret_conv;
14633 }
14634
14635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14636         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14637         COption_NoneZ_free(_res_conv);
14638 }
14639
14640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14641         LDKCounterpartyChannelTransactionParameters o_conv;
14642         o_conv.inner = (void*)(o & (~1));
14643         o_conv.is_owned = (o & 1) || (o == 0);
14644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14645         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14646         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14647         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14648         return (int64_t)ret_conv;
14649 }
14650
14651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14652         LDKDecodeError e_conv;
14653         e_conv.inner = (void*)(e & (~1));
14654         e_conv.is_owned = (e & 1) || (e == 0);
14655         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14656         e_conv = DecodeError_clone(&e_conv);
14657         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14658         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14659         return (int64_t)ret_conv;
14660 }
14661
14662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14663         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14664         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14665         return ret_conv;
14666 }
14667
14668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14669         if ((_res & 1) != 0) return;
14670         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14671         CHECK_ACCESS(_res_ptr);
14672         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14673         FREE((void*)_res);
14674         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14675 }
14676
14677 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14678         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14679         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14680         return (int64_t)ret_conv;
14681 }
14682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14683         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14684         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14685         return ret_conv;
14686 }
14687
14688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14689         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14690         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14691         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14692         return (int64_t)ret_conv;
14693 }
14694
14695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14696         LDKChannelTransactionParameters o_conv;
14697         o_conv.inner = (void*)(o & (~1));
14698         o_conv.is_owned = (o & 1) || (o == 0);
14699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14700         o_conv = ChannelTransactionParameters_clone(&o_conv);
14701         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14702         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14703         return (int64_t)ret_conv;
14704 }
14705
14706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14707         LDKDecodeError e_conv;
14708         e_conv.inner = (void*)(e & (~1));
14709         e_conv.is_owned = (e & 1) || (e == 0);
14710         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14711         e_conv = DecodeError_clone(&e_conv);
14712         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14713         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
14714         return (int64_t)ret_conv;
14715 }
14716
14717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14718         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14719         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14720         return ret_conv;
14721 }
14722
14723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14724         if ((_res & 1) != 0) return;
14725         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14726         CHECK_ACCESS(_res_ptr);
14727         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14728         FREE((void*)_res);
14729         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14730 }
14731
14732 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14733         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14734         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
14735         return (int64_t)ret_conv;
14736 }
14737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14738         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14739         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14740         return ret_conv;
14741 }
14742
14743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14744         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14745         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14746         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14747         return (int64_t)ret_conv;
14748 }
14749
14750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14751         LDKCVec_SignatureZ _res_constr;
14752         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14753         if (_res_constr.datalen > 0)
14754                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14755         else
14756                 _res_constr.data = NULL;
14757         for (size_t i = 0; i < _res_constr.datalen; i++) {
14758                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14759                 LDKSignature _res_conv_8_ref;
14760                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
14761                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
14762                 _res_constr.data[i] = _res_conv_8_ref;
14763         }
14764         CVec_SignatureZ_free(_res_constr);
14765 }
14766
14767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14768         LDKHolderCommitmentTransaction o_conv;
14769         o_conv.inner = (void*)(o & (~1));
14770         o_conv.is_owned = (o & 1) || (o == 0);
14771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14772         o_conv = HolderCommitmentTransaction_clone(&o_conv);
14773         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14774         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
14775         return (int64_t)ret_conv;
14776 }
14777
14778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14779         LDKDecodeError e_conv;
14780         e_conv.inner = (void*)(e & (~1));
14781         e_conv.is_owned = (e & 1) || (e == 0);
14782         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14783         e_conv = DecodeError_clone(&e_conv);
14784         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14785         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
14786         return (int64_t)ret_conv;
14787 }
14788
14789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14790         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
14791         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14792         return ret_conv;
14793 }
14794
14795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14796         if ((_res & 1) != 0) return;
14797         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14798         CHECK_ACCESS(_res_ptr);
14799         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14800         FREE((void*)_res);
14801         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
14802 }
14803
14804 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14805         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14806         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
14807         return (int64_t)ret_conv;
14808 }
14809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14810         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14811         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14812         return ret_conv;
14813 }
14814
14815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14816         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14817         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14818         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14819         return (int64_t)ret_conv;
14820 }
14821
14822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14823         LDKBuiltCommitmentTransaction o_conv;
14824         o_conv.inner = (void*)(o & (~1));
14825         o_conv.is_owned = (o & 1) || (o == 0);
14826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14827         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
14828         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14829         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
14830         return (int64_t)ret_conv;
14831 }
14832
14833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14834         LDKDecodeError e_conv;
14835         e_conv.inner = (void*)(e & (~1));
14836         e_conv.is_owned = (e & 1) || (e == 0);
14837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14838         e_conv = DecodeError_clone(&e_conv);
14839         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14840         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
14841         return (int64_t)ret_conv;
14842 }
14843
14844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14845         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
14846         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14847         return ret_conv;
14848 }
14849
14850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14851         if ((_res & 1) != 0) return;
14852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14853         CHECK_ACCESS(_res_ptr);
14854         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14855         FREE((void*)_res);
14856         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
14857 }
14858
14859 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14860         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14861         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
14862         return (int64_t)ret_conv;
14863 }
14864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14865         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14866         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14867         return ret_conv;
14868 }
14869
14870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14871         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14872         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14873         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14874         return (int64_t)ret_conv;
14875 }
14876
14877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14878         LDKTrustedClosingTransaction o_conv;
14879         o_conv.inner = (void*)(o & (~1));
14880         o_conv.is_owned = (o & 1) || (o == 0);
14881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14882         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
14883         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14884         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
14885         return (int64_t)ret_conv;
14886 }
14887
14888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14889         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14890         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
14891         return (int64_t)ret_conv;
14892 }
14893
14894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14895         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
14896         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
14897         return ret_conv;
14898 }
14899
14900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14901         if ((_res & 1) != 0) return;
14902         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14903         CHECK_ACCESS(_res_ptr);
14904         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
14905         FREE((void*)_res);
14906         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
14907 }
14908
14909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14910         LDKCommitmentTransaction o_conv;
14911         o_conv.inner = (void*)(o & (~1));
14912         o_conv.is_owned = (o & 1) || (o == 0);
14913         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14914         o_conv = CommitmentTransaction_clone(&o_conv);
14915         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14916         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
14917         return (int64_t)ret_conv;
14918 }
14919
14920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14921         LDKDecodeError e_conv;
14922         e_conv.inner = (void*)(e & (~1));
14923         e_conv.is_owned = (e & 1) || (e == 0);
14924         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14925         e_conv = DecodeError_clone(&e_conv);
14926         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14927         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
14928         return (int64_t)ret_conv;
14929 }
14930
14931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14932         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
14933         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14934         return ret_conv;
14935 }
14936
14937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14938         if ((_res & 1) != 0) return;
14939         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14940         CHECK_ACCESS(_res_ptr);
14941         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
14942         FREE((void*)_res);
14943         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
14944 }
14945
14946 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14947         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14948         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
14949         return (int64_t)ret_conv;
14950 }
14951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14952         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
14953         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14954         return ret_conv;
14955 }
14956
14957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14958         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
14959         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14960         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
14961         return (int64_t)ret_conv;
14962 }
14963
14964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14965         LDKTrustedCommitmentTransaction o_conv;
14966         o_conv.inner = (void*)(o & (~1));
14967         o_conv.is_owned = (o & 1) || (o == 0);
14968         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14969         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
14970         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14971         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
14972         return (int64_t)ret_conv;
14973 }
14974
14975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14976         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14977         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
14978         return (int64_t)ret_conv;
14979 }
14980
14981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14982         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
14983         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
14984         return ret_conv;
14985 }
14986
14987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14988         if ((_res & 1) != 0) return;
14989         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14990         CHECK_ACCESS(_res_ptr);
14991         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
14992         FREE((void*)_res);
14993         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
14994 }
14995
14996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14997         LDKCVec_SignatureZ o_constr;
14998         o_constr.datalen = (*env)->GetArrayLength(env, o);
14999         if (o_constr.datalen > 0)
15000                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15001         else
15002                 o_constr.data = NULL;
15003         for (size_t i = 0; i < o_constr.datalen; i++) {
15004                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15005                 LDKSignature o_conv_8_ref;
15006                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15007                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15008                 o_constr.data[i] = o_conv_8_ref;
15009         }
15010         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15011         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15012         return (int64_t)ret_conv;
15013 }
15014
15015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15016         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15017         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15018         return (int64_t)ret_conv;
15019 }
15020
15021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15022         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15023         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15024         return ret_conv;
15025 }
15026
15027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15028         if ((_res & 1) != 0) return;
15029         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15030         CHECK_ACCESS(_res_ptr);
15031         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15032         FREE((void*)_res);
15033         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15034 }
15035
15036 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15037         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15038         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15039         return (int64_t)ret_conv;
15040 }
15041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15042         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15043         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15044         return ret_conv;
15045 }
15046
15047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15048         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15049         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15050         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15051         return (int64_t)ret_conv;
15052 }
15053
15054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15055         LDKShutdownScript o_conv;
15056         o_conv.inner = (void*)(o & (~1));
15057         o_conv.is_owned = (o & 1) || (o == 0);
15058         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15059         o_conv = ShutdownScript_clone(&o_conv);
15060         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15061         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15062         return (int64_t)ret_conv;
15063 }
15064
15065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15066         LDKDecodeError e_conv;
15067         e_conv.inner = (void*)(e & (~1));
15068         e_conv.is_owned = (e & 1) || (e == 0);
15069         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15070         e_conv = DecodeError_clone(&e_conv);
15071         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15072         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15073         return (int64_t)ret_conv;
15074 }
15075
15076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15077         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15078         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15079         return ret_conv;
15080 }
15081
15082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15083         if ((_res & 1) != 0) return;
15084         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15085         CHECK_ACCESS(_res_ptr);
15086         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15087         FREE((void*)_res);
15088         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15089 }
15090
15091 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15092         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15093         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15094         return (int64_t)ret_conv;
15095 }
15096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15097         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15098         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15099         return ret_conv;
15100 }
15101
15102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15103         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15104         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15105         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15106         return (int64_t)ret_conv;
15107 }
15108
15109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15110         LDKShutdownScript o_conv;
15111         o_conv.inner = (void*)(o & (~1));
15112         o_conv.is_owned = (o & 1) || (o == 0);
15113         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15114         o_conv = ShutdownScript_clone(&o_conv);
15115         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15116         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15117         return (int64_t)ret_conv;
15118 }
15119
15120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15121         LDKInvalidShutdownScript e_conv;
15122         e_conv.inner = (void*)(e & (~1));
15123         e_conv.is_owned = (e & 1) || (e == 0);
15124         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15125         e_conv = InvalidShutdownScript_clone(&e_conv);
15126         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15127         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15128         return (int64_t)ret_conv;
15129 }
15130
15131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15132         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15133         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15134         return ret_conv;
15135 }
15136
15137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15138         if ((_res & 1) != 0) return;
15139         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15140         CHECK_ACCESS(_res_ptr);
15141         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15142         FREE((void*)_res);
15143         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15144 }
15145
15146 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15147         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15148         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15149         return (int64_t)ret_conv;
15150 }
15151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15152         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15153         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15154         return ret_conv;
15155 }
15156
15157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15158         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15159         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15160         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15161         return (int64_t)ret_conv;
15162 }
15163
15164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15165         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15166         *ret_conv = CResult_NoneErrorZ_ok();
15167         return (int64_t)ret_conv;
15168 }
15169
15170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15171         LDKIOError e_conv = LDKIOError_from_java(env, e);
15172         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15173         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15174         return (int64_t)ret_conv;
15175 }
15176
15177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15178         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15179         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15180         return ret_conv;
15181 }
15182
15183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15184         if ((_res & 1) != 0) return;
15185         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15186         CHECK_ACCESS(_res_ptr);
15187         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15188         FREE((void*)_res);
15189         CResult_NoneErrorZ_free(_res_conv);
15190 }
15191
15192 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15193         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15194         *ret_conv = CResult_NoneErrorZ_clone(arg);
15195         return (int64_t)ret_conv;
15196 }
15197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15198         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15199         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15200         return ret_conv;
15201 }
15202
15203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15204         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15205         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15206         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15207         return (int64_t)ret_conv;
15208 }
15209
15210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15211         LDKRouteHop o_conv;
15212         o_conv.inner = (void*)(o & (~1));
15213         o_conv.is_owned = (o & 1) || (o == 0);
15214         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15215         o_conv = RouteHop_clone(&o_conv);
15216         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15217         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15218         return (int64_t)ret_conv;
15219 }
15220
15221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15222         LDKDecodeError e_conv;
15223         e_conv.inner = (void*)(e & (~1));
15224         e_conv.is_owned = (e & 1) || (e == 0);
15225         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15226         e_conv = DecodeError_clone(&e_conv);
15227         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15228         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15229         return (int64_t)ret_conv;
15230 }
15231
15232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15233         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15234         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15235         return ret_conv;
15236 }
15237
15238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15239         if ((_res & 1) != 0) return;
15240         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15241         CHECK_ACCESS(_res_ptr);
15242         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15243         FREE((void*)_res);
15244         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15245 }
15246
15247 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15248         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15249         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15250         return (int64_t)ret_conv;
15251 }
15252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15253         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15254         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15255         return ret_conv;
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15259         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15260         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15261         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15262         return (int64_t)ret_conv;
15263 }
15264
15265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15266         LDKCVec_RouteHopZ _res_constr;
15267         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15268         if (_res_constr.datalen > 0)
15269                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15270         else
15271                 _res_constr.data = NULL;
15272         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15273         for (size_t k = 0; k < _res_constr.datalen; k++) {
15274                 int64_t _res_conv_10 = _res_vals[k];
15275                 LDKRouteHop _res_conv_10_conv;
15276                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15277                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15278                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15279                 _res_constr.data[k] = _res_conv_10_conv;
15280         }
15281         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15282         CVec_RouteHopZ_free(_res_constr);
15283 }
15284
15285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15286         LDKCVec_CVec_RouteHopZZ _res_constr;
15287         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15288         if (_res_constr.datalen > 0)
15289                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
15290         else
15291                 _res_constr.data = NULL;
15292         for (size_t m = 0; m < _res_constr.datalen; m++) {
15293                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
15294                 LDKCVec_RouteHopZ _res_conv_12_constr;
15295                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
15296                 if (_res_conv_12_constr.datalen > 0)
15297                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15298                 else
15299                         _res_conv_12_constr.data = NULL;
15300                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
15301                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
15302                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
15303                         LDKRouteHop _res_conv_12_conv_10_conv;
15304                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
15305                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
15306                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
15307                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
15308                 }
15309                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
15310                 _res_constr.data[m] = _res_conv_12_constr;
15311         }
15312         CVec_CVec_RouteHopZZ_free(_res_constr);
15313 }
15314
15315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15316         LDKRoute o_conv;
15317         o_conv.inner = (void*)(o & (~1));
15318         o_conv.is_owned = (o & 1) || (o == 0);
15319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15320         o_conv = Route_clone(&o_conv);
15321         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15322         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
15323         return (int64_t)ret_conv;
15324 }
15325
15326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15327         LDKDecodeError e_conv;
15328         e_conv.inner = (void*)(e & (~1));
15329         e_conv.is_owned = (e & 1) || (e == 0);
15330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15331         e_conv = DecodeError_clone(&e_conv);
15332         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15333         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
15334         return (int64_t)ret_conv;
15335 }
15336
15337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15338         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
15339         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
15340         return ret_conv;
15341 }
15342
15343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15344         if ((_res & 1) != 0) return;
15345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15346         CHECK_ACCESS(_res_ptr);
15347         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
15348         FREE((void*)_res);
15349         CResult_RouteDecodeErrorZ_free(_res_conv);
15350 }
15351
15352 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
15353         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15354         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
15355         return (int64_t)ret_conv;
15356 }
15357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15358         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
15359         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
15360         return ret_conv;
15361 }
15362
15363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15364         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
15365         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15366         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
15367         return (int64_t)ret_conv;
15368 }
15369
15370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15371         LDKRouteParameters o_conv;
15372         o_conv.inner = (void*)(o & (~1));
15373         o_conv.is_owned = (o & 1) || (o == 0);
15374         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15375         o_conv = RouteParameters_clone(&o_conv);
15376         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15377         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
15378         return (int64_t)ret_conv;
15379 }
15380
15381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15382         LDKDecodeError e_conv;
15383         e_conv.inner = (void*)(e & (~1));
15384         e_conv.is_owned = (e & 1) || (e == 0);
15385         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15386         e_conv = DecodeError_clone(&e_conv);
15387         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15388         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
15389         return (int64_t)ret_conv;
15390 }
15391
15392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15393         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
15394         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
15395         return ret_conv;
15396 }
15397
15398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15399         if ((_res & 1) != 0) return;
15400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15401         CHECK_ACCESS(_res_ptr);
15402         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
15403         FREE((void*)_res);
15404         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
15405 }
15406
15407 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
15408         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15409         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
15410         return (int64_t)ret_conv;
15411 }
15412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15413         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
15414         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
15415         return ret_conv;
15416 }
15417
15418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15419         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
15420         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15421         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
15422         return (int64_t)ret_conv;
15423 }
15424
15425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15426         LDKCVec_RouteHintZ _res_constr;
15427         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15428         if (_res_constr.datalen > 0)
15429                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
15430         else
15431                 _res_constr.data = NULL;
15432         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15433         for (size_t l = 0; l < _res_constr.datalen; l++) {
15434                 int64_t _res_conv_11 = _res_vals[l];
15435                 LDKRouteHint _res_conv_11_conv;
15436                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15437                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15438                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15439                 _res_constr.data[l] = _res_conv_11_conv;
15440         }
15441         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15442         CVec_RouteHintZ_free(_res_constr);
15443 }
15444
15445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15446         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15447         *ret_copy = COption_u64Z_some(o);
15448         int64_t ret_ref = (uintptr_t)ret_copy;
15449         return ret_ref;
15450 }
15451
15452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15453         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15454         *ret_copy = COption_u64Z_none();
15455         int64_t ret_ref = (uintptr_t)ret_copy;
15456         return ret_ref;
15457 }
15458
15459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15460         if ((_res & 1) != 0) return;
15461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15462         CHECK_ACCESS(_res_ptr);
15463         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15464         FREE((void*)_res);
15465         COption_u64Z_free(_res_conv);
15466 }
15467
15468 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15469         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15470         *ret_copy = COption_u64Z_clone(arg);
15471 int64_t ret_ref = (uintptr_t)ret_copy;
15472         return ret_ref;
15473 }
15474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15475         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15476         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15477         return ret_conv;
15478 }
15479
15480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15481         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15482         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15483         *ret_copy = COption_u64Z_clone(orig_conv);
15484         int64_t ret_ref = (uintptr_t)ret_copy;
15485         return ret_ref;
15486 }
15487
15488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15489         LDKPaymentParameters o_conv;
15490         o_conv.inner = (void*)(o & (~1));
15491         o_conv.is_owned = (o & 1) || (o == 0);
15492         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15493         o_conv = PaymentParameters_clone(&o_conv);
15494         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15495         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15496         return (int64_t)ret_conv;
15497 }
15498
15499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15500         LDKDecodeError e_conv;
15501         e_conv.inner = (void*)(e & (~1));
15502         e_conv.is_owned = (e & 1) || (e == 0);
15503         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15504         e_conv = DecodeError_clone(&e_conv);
15505         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15506         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15507         return (int64_t)ret_conv;
15508 }
15509
15510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15511         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15512         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15513         return ret_conv;
15514 }
15515
15516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15517         if ((_res & 1) != 0) return;
15518         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15519         CHECK_ACCESS(_res_ptr);
15520         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15521         FREE((void*)_res);
15522         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15523 }
15524
15525 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15526         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15527         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15528         return (int64_t)ret_conv;
15529 }
15530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15531         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15532         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15533         return ret_conv;
15534 }
15535
15536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15537         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15538         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15539         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15540         return (int64_t)ret_conv;
15541 }
15542
15543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15544         LDKCVec_RouteHintHopZ _res_constr;
15545         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15546         if (_res_constr.datalen > 0)
15547                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15548         else
15549                 _res_constr.data = NULL;
15550         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15551         for (size_t o = 0; o < _res_constr.datalen; o++) {
15552                 int64_t _res_conv_14 = _res_vals[o];
15553                 LDKRouteHintHop _res_conv_14_conv;
15554                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15555                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15556                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15557                 _res_constr.data[o] = _res_conv_14_conv;
15558         }
15559         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15560         CVec_RouteHintHopZ_free(_res_constr);
15561 }
15562
15563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15564         LDKRouteHint o_conv;
15565         o_conv.inner = (void*)(o & (~1));
15566         o_conv.is_owned = (o & 1) || (o == 0);
15567         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15568         o_conv = RouteHint_clone(&o_conv);
15569         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15570         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15571         return (int64_t)ret_conv;
15572 }
15573
15574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15575         LDKDecodeError e_conv;
15576         e_conv.inner = (void*)(e & (~1));
15577         e_conv.is_owned = (e & 1) || (e == 0);
15578         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15579         e_conv = DecodeError_clone(&e_conv);
15580         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15581         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15582         return (int64_t)ret_conv;
15583 }
15584
15585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15586         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15587         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15588         return ret_conv;
15589 }
15590
15591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15592         if ((_res & 1) != 0) return;
15593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15594         CHECK_ACCESS(_res_ptr);
15595         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15596         FREE((void*)_res);
15597         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15598 }
15599
15600 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15601         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15602         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15603         return (int64_t)ret_conv;
15604 }
15605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15606         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
15607         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15608         return ret_conv;
15609 }
15610
15611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15612         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
15613         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15614         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15615         return (int64_t)ret_conv;
15616 }
15617
15618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15619         LDKRouteHintHop o_conv;
15620         o_conv.inner = (void*)(o & (~1));
15621         o_conv.is_owned = (o & 1) || (o == 0);
15622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15623         o_conv = RouteHintHop_clone(&o_conv);
15624         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15625         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15626         return (int64_t)ret_conv;
15627 }
15628
15629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15630         LDKDecodeError e_conv;
15631         e_conv.inner = (void*)(e & (~1));
15632         e_conv.is_owned = (e & 1) || (e == 0);
15633         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15634         e_conv = DecodeError_clone(&e_conv);
15635         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15636         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15637         return (int64_t)ret_conv;
15638 }
15639
15640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15641         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
15642         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15643         return ret_conv;
15644 }
15645
15646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15647         if ((_res & 1) != 0) return;
15648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15649         CHECK_ACCESS(_res_ptr);
15650         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15651         FREE((void*)_res);
15652         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15653 }
15654
15655 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15656         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15657         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15658         return (int64_t)ret_conv;
15659 }
15660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15661         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
15662         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15663         return ret_conv;
15664 }
15665
15666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15667         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
15668         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15669         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15670         return (int64_t)ret_conv;
15671 }
15672
15673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15674         LDKCVec_ChannelDetailsZ _res_constr;
15675         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15676         if (_res_constr.datalen > 0)
15677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15678         else
15679                 _res_constr.data = NULL;
15680         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15681         for (size_t q = 0; q < _res_constr.datalen; q++) {
15682                 int64_t _res_conv_16 = _res_vals[q];
15683                 LDKChannelDetails _res_conv_16_conv;
15684                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15685                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15686                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15687                 _res_constr.data[q] = _res_conv_16_conv;
15688         }
15689         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15690         CVec_ChannelDetailsZ_free(_res_constr);
15691 }
15692
15693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15694         LDKRoute o_conv;
15695         o_conv.inner = (void*)(o & (~1));
15696         o_conv.is_owned = (o & 1) || (o == 0);
15697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15698         o_conv = Route_clone(&o_conv);
15699         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15700         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
15701         return (int64_t)ret_conv;
15702 }
15703
15704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15705         LDKLightningError e_conv;
15706         e_conv.inner = (void*)(e & (~1));
15707         e_conv.is_owned = (e & 1) || (e == 0);
15708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15709         e_conv = LightningError_clone(&e_conv);
15710         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15711         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
15712         return (int64_t)ret_conv;
15713 }
15714
15715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15716         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
15717         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
15718         return ret_conv;
15719 }
15720
15721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15722         if ((_res & 1) != 0) return;
15723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15724         CHECK_ACCESS(_res_ptr);
15725         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
15726         FREE((void*)_res);
15727         CResult_RouteLightningErrorZ_free(_res_conv);
15728 }
15729
15730 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
15731         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15732         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
15733         return (int64_t)ret_conv;
15734 }
15735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15736         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
15737         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
15738         return ret_conv;
15739 }
15740
15741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15742         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
15743         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15744         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
15745         return (int64_t)ret_conv;
15746 }
15747
15748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15749         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15750         CHECK_ACCESS(o_ptr);
15751         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
15752         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
15753         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15754         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
15755         return (int64_t)ret_conv;
15756 }
15757
15758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15759         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
15760         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15761         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
15762         return (int64_t)ret_conv;
15763 }
15764
15765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15766         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
15767         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
15768         return ret_conv;
15769 }
15770
15771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15772         if ((_res & 1) != 0) return;
15773         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15774         CHECK_ACCESS(_res_ptr);
15775         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
15776         FREE((void*)_res);
15777         CResult_TxOutAccessErrorZ_free(_res_conv);
15778 }
15779
15780 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
15781         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15782         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
15783         return (int64_t)ret_conv;
15784 }
15785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15786         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
15787         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
15788         return ret_conv;
15789 }
15790
15791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15792         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
15793         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15794         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
15795         return (int64_t)ret_conv;
15796 }
15797
15798 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
15799         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15800         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
15801         return ((int64_t)ret_conv);
15802 }
15803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15804         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
15805         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
15806         return ret_conv;
15807 }
15808
15809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15810         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
15811         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15812         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
15813         return ((int64_t)ret_conv);
15814 }
15815
15816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15817         LDKTransaction b_ref;
15818         b_ref.datalen = (*env)->GetArrayLength(env, b);
15819         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
15820         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15821         b_ref.data_is_owned = true;
15822         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15823         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
15824         return ((int64_t)ret_conv);
15825 }
15826
15827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15828         if ((_res & 1) != 0) return;
15829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15830         CHECK_ACCESS(_res_ptr);
15831         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
15832         FREE((void*)_res);
15833         C2Tuple_usizeTransactionZ_free(_res_conv);
15834 }
15835
15836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15837         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
15838         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15839         if (_res_constr.datalen > 0)
15840                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15841         else
15842                 _res_constr.data = NULL;
15843         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15844         for (size_t c = 0; c < _res_constr.datalen; c++) {
15845                 int64_t _res_conv_28 = _res_vals[c];
15846                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
15847                 CHECK_ACCESS(_res_conv_28_ptr);
15848                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
15849                 FREE((void*)_res_conv_28);
15850                 _res_constr.data[c] = _res_conv_28_conv;
15851         }
15852         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15853         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
15854 }
15855
15856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15857         LDKCVec_TxidZ _res_constr;
15858         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15859         if (_res_constr.datalen > 0)
15860                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
15861         else
15862                 _res_constr.data = NULL;
15863         for (size_t i = 0; i < _res_constr.datalen; i++) {
15864                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15865                 LDKThirtyTwoBytes _res_conv_8_ref;
15866                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
15867                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
15868                 _res_constr.data[i] = _res_conv_8_ref;
15869         }
15870         CVec_TxidZ_free(_res_constr);
15871 }
15872
15873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
15874         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15875         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
15876         return (int64_t)ret_conv;
15877 }
15878
15879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
15880         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
15881         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15882         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
15883         return (int64_t)ret_conv;
15884 }
15885
15886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15887         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
15888         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
15889         return ret_conv;
15890 }
15891
15892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15893         if ((_res & 1) != 0) return;
15894         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15895         CHECK_ACCESS(_res_ptr);
15896         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
15897         FREE((void*)_res);
15898         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
15899 }
15900
15901 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
15902         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15903         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
15904         return (int64_t)ret_conv;
15905 }
15906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15907         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
15908         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
15909         return ret_conv;
15910 }
15911
15912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15913         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
15914         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15915         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
15916         return (int64_t)ret_conv;
15917 }
15918
15919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15920         LDKCVec_MonitorEventZ _res_constr;
15921         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15922         if (_res_constr.datalen > 0)
15923                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15924         else
15925                 _res_constr.data = NULL;
15926         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15927         for (size_t o = 0; o < _res_constr.datalen; o++) {
15928                 int64_t _res_conv_14 = _res_vals[o];
15929                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
15930                 CHECK_ACCESS(_res_conv_14_ptr);
15931                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
15932                 FREE((void*)_res_conv_14);
15933                 _res_constr.data[o] = _res_conv_14_conv;
15934         }
15935         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15936         CVec_MonitorEventZ_free(_res_constr);
15937 }
15938
15939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15940         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15941         CHECK_ACCESS(o_ptr);
15942         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
15943         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
15944         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15945         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
15946         int64_t ret_ref = (uintptr_t)ret_copy;
15947         return ret_ref;
15948 }
15949
15950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
15951         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15952         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
15953         int64_t ret_ref = (uintptr_t)ret_copy;
15954         return ret_ref;
15955 }
15956
15957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15958         if ((_res & 1) != 0) return;
15959         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15960         CHECK_ACCESS(_res_ptr);
15961         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
15962         FREE((void*)_res);
15963         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
15964 }
15965
15966 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
15967         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15968         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
15969 int64_t ret_ref = (uintptr_t)ret_copy;
15970         return ret_ref;
15971 }
15972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15973         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
15974         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
15975         return ret_conv;
15976 }
15977
15978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15979         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
15980         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15981         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
15982         int64_t ret_ref = (uintptr_t)ret_copy;
15983         return ret_ref;
15984 }
15985
15986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15987         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15988         CHECK_ACCESS(o_ptr);
15989         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
15990         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
15991         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15992         *ret_copy = COption_ClosureReasonZ_some(o_conv);
15993         int64_t ret_ref = (uintptr_t)ret_copy;
15994         return ret_ref;
15995 }
15996
15997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
15998         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15999         *ret_copy = COption_ClosureReasonZ_none();
16000         int64_t ret_ref = (uintptr_t)ret_copy;
16001         return ret_ref;
16002 }
16003
16004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16005         if ((_res & 1) != 0) return;
16006         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16007         CHECK_ACCESS(_res_ptr);
16008         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16009         FREE((void*)_res);
16010         COption_ClosureReasonZ_free(_res_conv);
16011 }
16012
16013 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16014         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16015         *ret_copy = COption_ClosureReasonZ_clone(arg);
16016 int64_t ret_ref = (uintptr_t)ret_copy;
16017         return ret_ref;
16018 }
16019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16020         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16021         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16022         return ret_conv;
16023 }
16024
16025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16026         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16027         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16028         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16029         int64_t ret_ref = (uintptr_t)ret_copy;
16030         return ret_ref;
16031 }
16032
16033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16034         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16035         CHECK_ACCESS(o_ptr);
16036         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16037         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16038         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16039         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16040         return (int64_t)ret_conv;
16041 }
16042
16043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16044         LDKDecodeError e_conv;
16045         e_conv.inner = (void*)(e & (~1));
16046         e_conv.is_owned = (e & 1) || (e == 0);
16047         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16048         e_conv = DecodeError_clone(&e_conv);
16049         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16050         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16051         return (int64_t)ret_conv;
16052 }
16053
16054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16055         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16056         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16057         return ret_conv;
16058 }
16059
16060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16061         if ((_res & 1) != 0) return;
16062         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16063         CHECK_ACCESS(_res_ptr);
16064         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16065         FREE((void*)_res);
16066         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16067 }
16068
16069 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16070         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16071         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16072         return (int64_t)ret_conv;
16073 }
16074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16075         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16076         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16077         return ret_conv;
16078 }
16079
16080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16081         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16082         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16083         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16084         return (int64_t)ret_conv;
16085 }
16086
16087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16088         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16089         CHECK_ACCESS(o_ptr);
16090         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16091         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16092         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16093         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16094         int64_t ret_ref = (uintptr_t)ret_copy;
16095         return ret_ref;
16096 }
16097
16098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16099         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16100         *ret_copy = COption_NetworkUpdateZ_none();
16101         int64_t ret_ref = (uintptr_t)ret_copy;
16102         return ret_ref;
16103 }
16104
16105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16106         if ((_res & 1) != 0) return;
16107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16108         CHECK_ACCESS(_res_ptr);
16109         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16110         FREE((void*)_res);
16111         COption_NetworkUpdateZ_free(_res_conv);
16112 }
16113
16114 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16115         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16116         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16117 int64_t ret_ref = (uintptr_t)ret_copy;
16118         return ret_ref;
16119 }
16120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16121         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16122         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16123         return ret_conv;
16124 }
16125
16126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16127         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16128         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16129         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16130         int64_t ret_ref = (uintptr_t)ret_copy;
16131         return ret_ref;
16132 }
16133
16134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16135         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16136         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16137         if (_res_constr.datalen > 0)
16138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16139         else
16140                 _res_constr.data = NULL;
16141         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16142         for (size_t b = 0; b < _res_constr.datalen; b++) {
16143                 int64_t _res_conv_27 = _res_vals[b];
16144                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16145                 CHECK_ACCESS(_res_conv_27_ptr);
16146                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16147                 FREE((void*)_res_conv_27);
16148                 _res_constr.data[b] = _res_conv_27_conv;
16149         }
16150         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16151         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16152 }
16153
16154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16155         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16156         CHECK_ACCESS(o_ptr);
16157         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16158         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16159         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16160         *ret_copy = COption_EventZ_some(o_conv);
16161         int64_t ret_ref = (uintptr_t)ret_copy;
16162         return ret_ref;
16163 }
16164
16165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16166         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16167         *ret_copy = COption_EventZ_none();
16168         int64_t ret_ref = (uintptr_t)ret_copy;
16169         return ret_ref;
16170 }
16171
16172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16173         if ((_res & 1) != 0) return;
16174         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16175         CHECK_ACCESS(_res_ptr);
16176         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16177         FREE((void*)_res);
16178         COption_EventZ_free(_res_conv);
16179 }
16180
16181 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16182         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16183         *ret_copy = COption_EventZ_clone(arg);
16184 int64_t ret_ref = (uintptr_t)ret_copy;
16185         return ret_ref;
16186 }
16187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16188         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16189         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16190         return ret_conv;
16191 }
16192
16193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16194         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16195         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16196         *ret_copy = COption_EventZ_clone(orig_conv);
16197         int64_t ret_ref = (uintptr_t)ret_copy;
16198         return ret_ref;
16199 }
16200
16201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16202         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16203         CHECK_ACCESS(o_ptr);
16204         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16205         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16206         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16207         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16208         return (int64_t)ret_conv;
16209 }
16210
16211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16212         LDKDecodeError e_conv;
16213         e_conv.inner = (void*)(e & (~1));
16214         e_conv.is_owned = (e & 1) || (e == 0);
16215         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16216         e_conv = DecodeError_clone(&e_conv);
16217         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16218         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16219         return (int64_t)ret_conv;
16220 }
16221
16222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16223         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16224         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16225         return ret_conv;
16226 }
16227
16228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16229         if ((_res & 1) != 0) return;
16230         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16231         CHECK_ACCESS(_res_ptr);
16232         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16233         FREE((void*)_res);
16234         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16235 }
16236
16237 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16238         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16239         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16240         return (int64_t)ret_conv;
16241 }
16242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16243         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16244         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16245         return ret_conv;
16246 }
16247
16248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16249         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16250         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16251         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16252         return (int64_t)ret_conv;
16253 }
16254
16255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16256         LDKCVec_MessageSendEventZ _res_constr;
16257         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16258         if (_res_constr.datalen > 0)
16259                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16260         else
16261                 _res_constr.data = NULL;
16262         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16263         for (size_t s = 0; s < _res_constr.datalen; s++) {
16264                 int64_t _res_conv_18 = _res_vals[s];
16265                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16266                 CHECK_ACCESS(_res_conv_18_ptr);
16267                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16268                 FREE((void*)_res_conv_18);
16269                 _res_constr.data[s] = _res_conv_18_conv;
16270         }
16271         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16272         CVec_MessageSendEventZ_free(_res_constr);
16273 }
16274
16275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16276         LDKFixedPenaltyScorer o_conv;
16277         o_conv.inner = (void*)(o & (~1));
16278         o_conv.is_owned = (o & 1) || (o == 0);
16279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16280         o_conv = FixedPenaltyScorer_clone(&o_conv);
16281         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16282         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
16283         return (int64_t)ret_conv;
16284 }
16285
16286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16287         LDKDecodeError e_conv;
16288         e_conv.inner = (void*)(e & (~1));
16289         e_conv.is_owned = (e & 1) || (e == 0);
16290         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16291         e_conv = DecodeError_clone(&e_conv);
16292         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16293         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16294         return (int64_t)ret_conv;
16295 }
16296
16297 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16298         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
16299         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16300         return ret_conv;
16301 }
16302
16303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16304         if ((_res & 1) != 0) return;
16305         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16306         CHECK_ACCESS(_res_ptr);
16307         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16308         FREE((void*)_res);
16309         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16310 }
16311
16312 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16313         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16314         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16315         return (int64_t)ret_conv;
16316 }
16317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16318         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
16319         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16320         return ret_conv;
16321 }
16322
16323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16324         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
16325         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16326         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16327         return (int64_t)ret_conv;
16328 }
16329
16330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16331         LDKScoringParameters o_conv;
16332         o_conv.inner = (void*)(o & (~1));
16333         o_conv.is_owned = (o & 1) || (o == 0);
16334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16335         o_conv = ScoringParameters_clone(&o_conv);
16336         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16337         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
16338         return (int64_t)ret_conv;
16339 }
16340
16341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16342         LDKDecodeError e_conv;
16343         e_conv.inner = (void*)(e & (~1));
16344         e_conv.is_owned = (e & 1) || (e == 0);
16345         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16346         e_conv = DecodeError_clone(&e_conv);
16347         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16348         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
16349         return (int64_t)ret_conv;
16350 }
16351
16352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16353         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
16354         jboolean ret_conv = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
16355         return ret_conv;
16356 }
16357
16358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16359         if ((_res & 1) != 0) return;
16360         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16361         CHECK_ACCESS(_res_ptr);
16362         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
16363         FREE((void*)_res);
16364         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
16365 }
16366
16367 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
16368         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16369         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
16370         return (int64_t)ret_conv;
16371 }
16372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16373         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
16374         int64_t ret_conv = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
16375         return ret_conv;
16376 }
16377
16378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16379         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
16380         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16381         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
16382         return (int64_t)ret_conv;
16383 }
16384
16385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16386         LDKScorer o_conv;
16387         o_conv.inner = (void*)(o & (~1));
16388         o_conv.is_owned = (o & 1) || (o == 0);
16389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16390         // WARNING: we need a move here but no clone is available for LDKScorer
16391         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
16392         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
16393         return (int64_t)ret_conv;
16394 }
16395
16396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16397         LDKDecodeError e_conv;
16398         e_conv.inner = (void*)(e & (~1));
16399         e_conv.is_owned = (e & 1) || (e == 0);
16400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16401         e_conv = DecodeError_clone(&e_conv);
16402         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
16403         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
16404         return (int64_t)ret_conv;
16405 }
16406
16407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16408         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
16409         jboolean ret_conv = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
16410         return ret_conv;
16411 }
16412
16413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16414         if ((_res & 1) != 0) return;
16415         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16416         CHECK_ACCESS(_res_ptr);
16417         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
16418         FREE((void*)_res);
16419         CResult_ScorerDecodeErrorZ_free(_res_conv);
16420 }
16421
16422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16423         LDKProbabilisticScorer o_conv;
16424         o_conv.inner = (void*)(o & (~1));
16425         o_conv.is_owned = (o & 1) || (o == 0);
16426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16427         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16428         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16429         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16430         return (int64_t)ret_conv;
16431 }
16432
16433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16434         LDKDecodeError e_conv;
16435         e_conv.inner = (void*)(e & (~1));
16436         e_conv.is_owned = (e & 1) || (e == 0);
16437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16438         e_conv = DecodeError_clone(&e_conv);
16439         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16440         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16441         return (int64_t)ret_conv;
16442 }
16443
16444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16445         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
16446         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
16447         return ret_conv;
16448 }
16449
16450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16451         if ((_res & 1) != 0) return;
16452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16453         CHECK_ACCESS(_res_ptr);
16454         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
16455         FREE((void*)_res);
16456         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
16457 }
16458
16459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16460         LDKInitFeatures o_conv;
16461         o_conv.inner = (void*)(o & (~1));
16462         o_conv.is_owned = (o & 1) || (o == 0);
16463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16464         o_conv = InitFeatures_clone(&o_conv);
16465         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16466         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
16467         return (int64_t)ret_conv;
16468 }
16469
16470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16471         LDKDecodeError e_conv;
16472         e_conv.inner = (void*)(e & (~1));
16473         e_conv.is_owned = (e & 1) || (e == 0);
16474         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16475         e_conv = DecodeError_clone(&e_conv);
16476         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16477         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
16478         return (int64_t)ret_conv;
16479 }
16480
16481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16482         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
16483         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
16484         return ret_conv;
16485 }
16486
16487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16488         if ((_res & 1) != 0) return;
16489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16490         CHECK_ACCESS(_res_ptr);
16491         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16492         FREE((void*)_res);
16493         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16494 }
16495
16496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16497         LDKChannelFeatures o_conv;
16498         o_conv.inner = (void*)(o & (~1));
16499         o_conv.is_owned = (o & 1) || (o == 0);
16500         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16501         o_conv = ChannelFeatures_clone(&o_conv);
16502         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16503         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16504         return (int64_t)ret_conv;
16505 }
16506
16507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16508         LDKDecodeError e_conv;
16509         e_conv.inner = (void*)(e & (~1));
16510         e_conv.is_owned = (e & 1) || (e == 0);
16511         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16512         e_conv = DecodeError_clone(&e_conv);
16513         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16514         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16515         return (int64_t)ret_conv;
16516 }
16517
16518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16519         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
16520         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16521         return ret_conv;
16522 }
16523
16524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16525         if ((_res & 1) != 0) return;
16526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16527         CHECK_ACCESS(_res_ptr);
16528         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16529         FREE((void*)_res);
16530         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16531 }
16532
16533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16534         LDKNodeFeatures o_conv;
16535         o_conv.inner = (void*)(o & (~1));
16536         o_conv.is_owned = (o & 1) || (o == 0);
16537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16538         o_conv = NodeFeatures_clone(&o_conv);
16539         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16540         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16541         return (int64_t)ret_conv;
16542 }
16543
16544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16545         LDKDecodeError e_conv;
16546         e_conv.inner = (void*)(e & (~1));
16547         e_conv.is_owned = (e & 1) || (e == 0);
16548         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16549         e_conv = DecodeError_clone(&e_conv);
16550         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16551         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16552         return (int64_t)ret_conv;
16553 }
16554
16555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16556         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
16557         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16558         return ret_conv;
16559 }
16560
16561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16562         if ((_res & 1) != 0) return;
16563         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16564         CHECK_ACCESS(_res_ptr);
16565         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16566         FREE((void*)_res);
16567         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16568 }
16569
16570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16571         LDKInvoiceFeatures o_conv;
16572         o_conv.inner = (void*)(o & (~1));
16573         o_conv.is_owned = (o & 1) || (o == 0);
16574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16575         o_conv = InvoiceFeatures_clone(&o_conv);
16576         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16577         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16578         return (int64_t)ret_conv;
16579 }
16580
16581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16582         LDKDecodeError e_conv;
16583         e_conv.inner = (void*)(e & (~1));
16584         e_conv.is_owned = (e & 1) || (e == 0);
16585         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16586         e_conv = DecodeError_clone(&e_conv);
16587         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16588         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16589         return (int64_t)ret_conv;
16590 }
16591
16592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16593         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
16594         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
16595         return ret_conv;
16596 }
16597
16598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16599         if ((_res & 1) != 0) return;
16600         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16601         CHECK_ACCESS(_res_ptr);
16602         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
16603         FREE((void*)_res);
16604         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
16605 }
16606
16607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16608         LDKChannelTypeFeatures o_conv;
16609         o_conv.inner = (void*)(o & (~1));
16610         o_conv.is_owned = (o & 1) || (o == 0);
16611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16612         o_conv = ChannelTypeFeatures_clone(&o_conv);
16613         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16614         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
16615         return (int64_t)ret_conv;
16616 }
16617
16618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16619         LDKDecodeError e_conv;
16620         e_conv.inner = (void*)(e & (~1));
16621         e_conv.is_owned = (e & 1) || (e == 0);
16622         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16623         e_conv = DecodeError_clone(&e_conv);
16624         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16625         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
16626         return (int64_t)ret_conv;
16627 }
16628
16629 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16630         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
16631         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
16632         return ret_conv;
16633 }
16634
16635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16636         if ((_res & 1) != 0) return;
16637         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16638         CHECK_ACCESS(_res_ptr);
16639         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
16640         FREE((void*)_res);
16641         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
16642 }
16643
16644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16645         LDKDelayedPaymentOutputDescriptor o_conv;
16646         o_conv.inner = (void*)(o & (~1));
16647         o_conv.is_owned = (o & 1) || (o == 0);
16648         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16649         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16650         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16651         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16652         return (int64_t)ret_conv;
16653 }
16654
16655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16656         LDKDecodeError e_conv;
16657         e_conv.inner = (void*)(e & (~1));
16658         e_conv.is_owned = (e & 1) || (e == 0);
16659         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16660         e_conv = DecodeError_clone(&e_conv);
16661         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16662         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16663         return (int64_t)ret_conv;
16664 }
16665
16666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16667         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16668         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16669         return ret_conv;
16670 }
16671
16672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16673         if ((_res & 1) != 0) return;
16674         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16675         CHECK_ACCESS(_res_ptr);
16676         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16677         FREE((void*)_res);
16678         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16679 }
16680
16681 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16682         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16683         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16684         return (int64_t)ret_conv;
16685 }
16686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16687         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16688         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16689         return ret_conv;
16690 }
16691
16692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16693         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16694         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16695         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16696         return (int64_t)ret_conv;
16697 }
16698
16699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16700         LDKStaticPaymentOutputDescriptor o_conv;
16701         o_conv.inner = (void*)(o & (~1));
16702         o_conv.is_owned = (o & 1) || (o == 0);
16703         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16704         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16705         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16706         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16707         return (int64_t)ret_conv;
16708 }
16709
16710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16711         LDKDecodeError e_conv;
16712         e_conv.inner = (void*)(e & (~1));
16713         e_conv.is_owned = (e & 1) || (e == 0);
16714         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16715         e_conv = DecodeError_clone(&e_conv);
16716         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16717         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16718         return (int64_t)ret_conv;
16719 }
16720
16721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16722         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16723         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16724         return ret_conv;
16725 }
16726
16727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16728         if ((_res & 1) != 0) return;
16729         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16730         CHECK_ACCESS(_res_ptr);
16731         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16732         FREE((void*)_res);
16733         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16734 }
16735
16736 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16737         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16738         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16739         return (int64_t)ret_conv;
16740 }
16741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16742         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16743         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16744         return ret_conv;
16745 }
16746
16747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16748         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16749         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16750         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16751         return (int64_t)ret_conv;
16752 }
16753
16754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16755         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16756         CHECK_ACCESS(o_ptr);
16757         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16758         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
16759         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16760         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16761         return (int64_t)ret_conv;
16762 }
16763
16764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16765         LDKDecodeError e_conv;
16766         e_conv.inner = (void*)(e & (~1));
16767         e_conv.is_owned = (e & 1) || (e == 0);
16768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16769         e_conv = DecodeError_clone(&e_conv);
16770         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16771         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16772         return (int64_t)ret_conv;
16773 }
16774
16775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16776         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
16777         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16778         return ret_conv;
16779 }
16780
16781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16782         if ((_res & 1) != 0) return;
16783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16784         CHECK_ACCESS(_res_ptr);
16785         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16786         FREE((void*)_res);
16787         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16788 }
16789
16790 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16791         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16792         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16793         return (int64_t)ret_conv;
16794 }
16795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16796         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
16797         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16798         return ret_conv;
16799 }
16800
16801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16802         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
16803         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16804         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16805         return (int64_t)ret_conv;
16806 }
16807
16808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16809         LDKCVec_PaymentPreimageZ _res_constr;
16810         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16811         if (_res_constr.datalen > 0)
16812                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
16813         else
16814                 _res_constr.data = NULL;
16815         for (size_t i = 0; i < _res_constr.datalen; i++) {
16816                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16817                 LDKThirtyTwoBytes _res_conv_8_ref;
16818                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16819                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16820                 _res_constr.data[i] = _res_conv_8_ref;
16821         }
16822         CVec_PaymentPreimageZ_free(_res_constr);
16823 }
16824
16825 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
16826         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16827         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
16828         return ((int64_t)ret_conv);
16829 }
16830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16831         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
16832         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
16833         return ret_conv;
16834 }
16835
16836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16837         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
16838         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16839         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
16840         return ((int64_t)ret_conv);
16841 }
16842
16843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
16844         LDKSignature a_ref;
16845         CHECK((*env)->GetArrayLength(env, a) == 64);
16846         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16847         LDKCVec_SignatureZ b_constr;
16848         b_constr.datalen = (*env)->GetArrayLength(env, b);
16849         if (b_constr.datalen > 0)
16850                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16851         else
16852                 b_constr.data = NULL;
16853         for (size_t i = 0; i < b_constr.datalen; i++) {
16854                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
16855                 LDKSignature b_conv_8_ref;
16856                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
16857                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
16858                 b_constr.data[i] = b_conv_8_ref;
16859         }
16860         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16861         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
16862         return ((int64_t)ret_conv);
16863 }
16864
16865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16866         if ((_res & 1) != 0) return;
16867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16868         CHECK_ACCESS(_res_ptr);
16869         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
16870         FREE((void*)_res);
16871         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
16872 }
16873
16874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16875         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16876         CHECK_ACCESS(o_ptr);
16877         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
16878         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
16879         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16880         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
16881         return (int64_t)ret_conv;
16882 }
16883
16884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
16885         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16886         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
16887         return (int64_t)ret_conv;
16888 }
16889
16890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16891         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
16892         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
16893         return ret_conv;
16894 }
16895
16896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16897         if ((_res & 1) != 0) return;
16898         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16899         CHECK_ACCESS(_res_ptr);
16900         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
16901         FREE((void*)_res);
16902         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
16903 }
16904
16905 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
16906         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16907         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
16908         return (int64_t)ret_conv;
16909 }
16910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16911         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
16912         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
16913         return ret_conv;
16914 }
16915
16916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16917         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
16918         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16919         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
16920         return (int64_t)ret_conv;
16921 }
16922
16923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16924         LDKSignature o_ref;
16925         CHECK((*env)->GetArrayLength(env, o) == 64);
16926         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
16927         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16928         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
16929         return (int64_t)ret_conv;
16930 }
16931
16932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16933         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16934         *ret_conv = CResult_SignatureNoneZ_err();
16935         return (int64_t)ret_conv;
16936 }
16937
16938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16939         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
16940         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
16941         return ret_conv;
16942 }
16943
16944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16945         if ((_res & 1) != 0) return;
16946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16947         CHECK_ACCESS(_res_ptr);
16948         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
16949         FREE((void*)_res);
16950         CResult_SignatureNoneZ_free(_res_conv);
16951 }
16952
16953 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
16954         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16955         *ret_conv = CResult_SignatureNoneZ_clone(arg);
16956         return (int64_t)ret_conv;
16957 }
16958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16959         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
16960         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
16961         return ret_conv;
16962 }
16963
16964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16965         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
16966         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16967         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
16968         return (int64_t)ret_conv;
16969 }
16970
16971 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
16972         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16973         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
16974         return ((int64_t)ret_conv);
16975 }
16976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16977         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
16978         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
16979         return ret_conv;
16980 }
16981
16982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16983         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
16984         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16985         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
16986         return ((int64_t)ret_conv);
16987 }
16988
16989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16990         LDKSignature a_ref;
16991         CHECK((*env)->GetArrayLength(env, a) == 64);
16992         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16993         LDKSignature b_ref;
16994         CHECK((*env)->GetArrayLength(env, b) == 64);
16995         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
16996         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16997         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
16998         return ((int64_t)ret_conv);
16999 }
17000
17001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17002         if ((_res & 1) != 0) return;
17003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17004         CHECK_ACCESS(_res_ptr);
17005         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
17006         FREE((void*)_res);
17007         C2Tuple_SignatureSignatureZ_free(_res_conv);
17008 }
17009
17010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17011         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17012         CHECK_ACCESS(o_ptr);
17013         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
17014         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
17015         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17016         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
17017         return (int64_t)ret_conv;
17018 }
17019
17020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
17021         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17022         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
17023         return (int64_t)ret_conv;
17024 }
17025
17026 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17027         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
17028         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
17029         return ret_conv;
17030 }
17031
17032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17033         if ((_res & 1) != 0) return;
17034         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17035         CHECK_ACCESS(_res_ptr);
17036         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
17037         FREE((void*)_res);
17038         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
17039 }
17040
17041 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
17042         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17043         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
17044         return (int64_t)ret_conv;
17045 }
17046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17047         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
17048         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
17049         return ret_conv;
17050 }
17051
17052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17053         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
17054         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17055         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
17056         return (int64_t)ret_conv;
17057 }
17058
17059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17060         LDKSecretKey o_ref;
17061         CHECK((*env)->GetArrayLength(env, o) == 32);
17062         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
17063         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17064         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
17065         return (int64_t)ret_conv;
17066 }
17067
17068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
17069         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17070         *ret_conv = CResult_SecretKeyNoneZ_err();
17071         return (int64_t)ret_conv;
17072 }
17073
17074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17075         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
17076         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
17077         return ret_conv;
17078 }
17079
17080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17081         if ((_res & 1) != 0) return;
17082         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17083         CHECK_ACCESS(_res_ptr);
17084         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
17085         FREE((void*)_res);
17086         CResult_SecretKeyNoneZ_free(_res_conv);
17087 }
17088
17089 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
17090         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17091         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
17092         return (int64_t)ret_conv;
17093 }
17094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17095         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
17096         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
17097         return ret_conv;
17098 }
17099
17100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17101         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
17102         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17103         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
17104         return (int64_t)ret_conv;
17105 }
17106
17107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17108         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17109         CHECK_ACCESS(o_ptr);
17110         LDKSign o_conv = *(LDKSign*)(o_ptr);
17111         if (o_conv.free == LDKSign_JCalls_free) {
17112                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17113                 LDKSign_JCalls_cloned(&o_conv);
17114         }
17115         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17116         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
17117         return (int64_t)ret_conv;
17118 }
17119
17120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17121         LDKDecodeError e_conv;
17122         e_conv.inner = (void*)(e & (~1));
17123         e_conv.is_owned = (e & 1) || (e == 0);
17124         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17125         e_conv = DecodeError_clone(&e_conv);
17126         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17127         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
17128         return (int64_t)ret_conv;
17129 }
17130
17131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17132         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
17133         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
17134         return ret_conv;
17135 }
17136
17137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17138         if ((_res & 1) != 0) return;
17139         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17140         CHECK_ACCESS(_res_ptr);
17141         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
17142         FREE((void*)_res);
17143         CResult_SignDecodeErrorZ_free(_res_conv);
17144 }
17145
17146 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
17147         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17148         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
17149         return (int64_t)ret_conv;
17150 }
17151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17152         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
17153         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
17154         return ret_conv;
17155 }
17156
17157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17158         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
17159         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17160         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
17161         return (int64_t)ret_conv;
17162 }
17163
17164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17165         LDKCVec_u5Z _res_constr;
17166         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17167         if (_res_constr.datalen > 0)
17168                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
17169         else
17170                 _res_constr.data = NULL;
17171         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
17172         for (size_t h = 0; h < _res_constr.datalen; h++) {
17173                 int8_t _res_conv_7 = _res_vals[h];
17174                 
17175                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
17176         }
17177         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
17178         CVec_u5Z_free(_res_constr);
17179 }
17180
17181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17182         LDKRecoverableSignature o_ref;
17183         CHECK((*env)->GetArrayLength(env, o) == 68);
17184         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
17185         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17186         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
17187         return (int64_t)ret_conv;
17188 }
17189
17190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
17191         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17192         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
17193         return (int64_t)ret_conv;
17194 }
17195
17196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17197         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
17198         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
17199         return ret_conv;
17200 }
17201
17202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17203         if ((_res & 1) != 0) return;
17204         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17205         CHECK_ACCESS(_res_ptr);
17206         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
17207         FREE((void*)_res);
17208         CResult_RecoverableSignatureNoneZ_free(_res_conv);
17209 }
17210
17211 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
17212         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17213         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
17214         return (int64_t)ret_conv;
17215 }
17216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17217         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
17218         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
17219         return ret_conv;
17220 }
17221
17222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17223         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
17224         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17225         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
17226         return (int64_t)ret_conv;
17227 }
17228
17229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
17230         LDKCVec_u8Z _res_ref;
17231         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
17232         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
17233         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
17234         CVec_u8Z_free(_res_ref);
17235 }
17236
17237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17238         LDKCVec_CVec_u8ZZ _res_constr;
17239         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17240         if (_res_constr.datalen > 0)
17241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17242         else
17243                 _res_constr.data = NULL;
17244         for (size_t i = 0; i < _res_constr.datalen; i++) {
17245                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17246                 LDKCVec_u8Z _res_conv_8_ref;
17247                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
17248                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17249                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
17250                 _res_constr.data[i] = _res_conv_8_ref;
17251         }
17252         CVec_CVec_u8ZZ_free(_res_constr);
17253 }
17254
17255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
17256         LDKCVec_CVec_u8ZZ o_constr;
17257         o_constr.datalen = (*env)->GetArrayLength(env, o);
17258         if (o_constr.datalen > 0)
17259                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17260         else
17261                 o_constr.data = NULL;
17262         for (size_t i = 0; i < o_constr.datalen; i++) {
17263                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
17264                 LDKCVec_u8Z o_conv_8_ref;
17265                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
17266                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17267                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
17268                 o_constr.data[i] = o_conv_8_ref;
17269         }
17270         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17271         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
17272         return (int64_t)ret_conv;
17273 }
17274
17275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
17276         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17277         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
17278         return (int64_t)ret_conv;
17279 }
17280
17281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17282         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
17283         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
17284         return ret_conv;
17285 }
17286
17287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17288         if ((_res & 1) != 0) return;
17289         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17290         CHECK_ACCESS(_res_ptr);
17291         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
17292         FREE((void*)_res);
17293         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
17294 }
17295
17296 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
17297         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17298         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
17299         return (int64_t)ret_conv;
17300 }
17301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17302         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
17303         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
17304         return ret_conv;
17305 }
17306
17307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17308         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
17309         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17310         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
17311         return (int64_t)ret_conv;
17312 }
17313
17314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17315         LDKInMemorySigner o_conv;
17316         o_conv.inner = (void*)(o & (~1));
17317         o_conv.is_owned = (o & 1) || (o == 0);
17318         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17319         o_conv = InMemorySigner_clone(&o_conv);
17320         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17321         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
17322         return (int64_t)ret_conv;
17323 }
17324
17325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17326         LDKDecodeError e_conv;
17327         e_conv.inner = (void*)(e & (~1));
17328         e_conv.is_owned = (e & 1) || (e == 0);
17329         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17330         e_conv = DecodeError_clone(&e_conv);
17331         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17332         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
17333         return (int64_t)ret_conv;
17334 }
17335
17336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17337         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
17338         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17339         return ret_conv;
17340 }
17341
17342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17343         if ((_res & 1) != 0) return;
17344         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17345         CHECK_ACCESS(_res_ptr);
17346         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17347         FREE((void*)_res);
17348         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17349 }
17350
17351 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17352         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17353         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17354         return (int64_t)ret_conv;
17355 }
17356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17357         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
17358         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17359         return ret_conv;
17360 }
17361
17362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17363         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
17364         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17365         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17366         return (int64_t)ret_conv;
17367 }
17368
17369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17370         LDKCVec_TxOutZ _res_constr;
17371         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17372         if (_res_constr.datalen > 0)
17373                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
17374         else
17375                 _res_constr.data = NULL;
17376         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17377         for (size_t h = 0; h < _res_constr.datalen; h++) {
17378                 int64_t _res_conv_7 = _res_vals[h];
17379                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17380                 CHECK_ACCESS(_res_conv_7_ptr);
17381                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
17382                 FREE((void*)_res_conv_7);
17383                 _res_constr.data[h] = _res_conv_7_conv;
17384         }
17385         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17386         CVec_TxOutZ_free(_res_constr);
17387 }
17388
17389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17390         LDKTransaction o_ref;
17391         o_ref.datalen = (*env)->GetArrayLength(env, o);
17392         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17393         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
17394         o_ref.data_is_owned = true;
17395         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17396         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17397         return (int64_t)ret_conv;
17398 }
17399
17400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17401         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17402         *ret_conv = CResult_TransactionNoneZ_err();
17403         return (int64_t)ret_conv;
17404 }
17405
17406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17407         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
17408         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
17409         return ret_conv;
17410 }
17411
17412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17413         if ((_res & 1) != 0) return;
17414         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17415         CHECK_ACCESS(_res_ptr);
17416         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17417         FREE((void*)_res);
17418         CResult_TransactionNoneZ_free(_res_conv);
17419 }
17420
17421 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
17422         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17423         *ret_conv = CResult_TransactionNoneZ_clone(arg);
17424         return (int64_t)ret_conv;
17425 }
17426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17427         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
17428         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
17429         return ret_conv;
17430 }
17431
17432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17433         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
17434         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17435         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
17436         return (int64_t)ret_conv;
17437 }
17438
17439 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17440         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17441         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17442         return ((int64_t)ret_conv);
17443 }
17444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17445         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17446         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17447         return ret_conv;
17448 }
17449
17450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17451         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17452         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17453         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17454         return ((int64_t)ret_conv);
17455 }
17456
17457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
17458         LDKThirtyTwoBytes a_ref;
17459         CHECK((*env)->GetArrayLength(env, a) == 32);
17460         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17461         LDKChannelMonitor b_conv;
17462         b_conv.inner = (void*)(b & (~1));
17463         b_conv.is_owned = (b & 1) || (b == 0);
17464         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17465         b_conv = ChannelMonitor_clone(&b_conv);
17466         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17467         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17468         return ((int64_t)ret_conv);
17469 }
17470
17471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17472         if ((_res & 1) != 0) return;
17473         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17474         CHECK_ACCESS(_res_ptr);
17475         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17476         FREE((void*)_res);
17477         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17478 }
17479
17480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17481         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
17482         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17483         if (_res_constr.datalen > 0)
17484                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17485         else
17486                 _res_constr.data = NULL;
17487         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17488         for (size_t j = 0; j < _res_constr.datalen; j++) {
17489                 int64_t _res_conv_35 = _res_vals[j];
17490                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
17491                 CHECK_ACCESS(_res_conv_35_ptr);
17492                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
17493                 FREE((void*)_res_conv_35);
17494                 _res_constr.data[j] = _res_conv_35_conv;
17495         }
17496         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17497         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
17498 }
17499
17500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
17501         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
17502         o_constr.datalen = (*env)->GetArrayLength(env, o);
17503         if (o_constr.datalen > 0)
17504                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17505         else
17506                 o_constr.data = NULL;
17507         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17508         for (size_t j = 0; j < o_constr.datalen; j++) {
17509                 int64_t o_conv_35 = o_vals[j];
17510                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
17511                 CHECK_ACCESS(o_conv_35_ptr);
17512                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
17513                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
17514                 o_constr.data[j] = o_conv_35_conv;
17515         }
17516         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17517         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17518         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
17519         return (int64_t)ret_conv;
17520 }
17521
17522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17523         LDKIOError e_conv = LDKIOError_from_java(env, e);
17524         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17525         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
17526         return (int64_t)ret_conv;
17527 }
17528
17529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17530         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
17531         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
17532         return ret_conv;
17533 }
17534
17535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17536         if ((_res & 1) != 0) return;
17537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17538         CHECK_ACCESS(_res_ptr);
17539         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
17540         FREE((void*)_res);
17541         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
17542 }
17543
17544 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
17545         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17546         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
17547         return (int64_t)ret_conv;
17548 }
17549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17550         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
17551         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
17552         return ret_conv;
17553 }
17554
17555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17556         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
17557         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17558         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
17559         return (int64_t)ret_conv;
17560 }
17561
17562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
17563         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17564         *ret_copy = COption_u16Z_some(o);
17565         int64_t ret_ref = (uintptr_t)ret_copy;
17566         return ret_ref;
17567 }
17568
17569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
17570         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17571         *ret_copy = COption_u16Z_none();
17572         int64_t ret_ref = (uintptr_t)ret_copy;
17573         return ret_ref;
17574 }
17575
17576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17577         if ((_res & 1) != 0) return;
17578         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17579         CHECK_ACCESS(_res_ptr);
17580         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17581         FREE((void*)_res);
17582         COption_u16Z_free(_res_conv);
17583 }
17584
17585 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17586         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17587         *ret_copy = COption_u16Z_clone(arg);
17588 int64_t ret_ref = (uintptr_t)ret_copy;
17589         return ret_ref;
17590 }
17591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17592         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
17593         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
17594         return ret_conv;
17595 }
17596
17597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17598         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
17599         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17600         *ret_copy = COption_u16Z_clone(orig_conv);
17601         int64_t ret_ref = (uintptr_t)ret_copy;
17602         return ret_ref;
17603 }
17604
17605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
17606         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17607         *ret_conv = CResult_NoneAPIErrorZ_ok();
17608         return (int64_t)ret_conv;
17609 }
17610
17611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17612         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17613         CHECK_ACCESS(e_ptr);
17614         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17615         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17616         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17617         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
17618         return (int64_t)ret_conv;
17619 }
17620
17621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17622         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
17623         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
17624         return ret_conv;
17625 }
17626
17627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17628         if ((_res & 1) != 0) return;
17629         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17630         CHECK_ACCESS(_res_ptr);
17631         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
17632         FREE((void*)_res);
17633         CResult_NoneAPIErrorZ_free(_res_conv);
17634 }
17635
17636 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
17637         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17638         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
17639         return (int64_t)ret_conv;
17640 }
17641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17642         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
17643         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
17644         return ret_conv;
17645 }
17646
17647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17648         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
17649         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17650         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
17651         return (int64_t)ret_conv;
17652 }
17653
17654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17655         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
17656         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17657         if (_res_constr.datalen > 0)
17658                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17659         else
17660                 _res_constr.data = NULL;
17661         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17662         for (size_t w = 0; w < _res_constr.datalen; w++) {
17663                 int64_t _res_conv_22 = _res_vals[w];
17664                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
17665                 CHECK_ACCESS(_res_conv_22_ptr);
17666                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
17667                 FREE((void*)_res_conv_22);
17668                 _res_constr.data[w] = _res_conv_22_conv;
17669         }
17670         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17671         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
17672 }
17673
17674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17675         LDKCVec_APIErrorZ _res_constr;
17676         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17677         if (_res_constr.datalen > 0)
17678                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17679         else
17680                 _res_constr.data = NULL;
17681         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17682         for (size_t k = 0; k < _res_constr.datalen; k++) {
17683                 int64_t _res_conv_10 = _res_vals[k];
17684                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
17685                 CHECK_ACCESS(_res_conv_10_ptr);
17686                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
17687                 FREE((void*)_res_conv_10);
17688                 _res_constr.data[k] = _res_conv_10_conv;
17689         }
17690         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17691         CVec_APIErrorZ_free(_res_constr);
17692 }
17693
17694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17695         LDKThirtyTwoBytes o_ref;
17696         CHECK((*env)->GetArrayLength(env, o) == 32);
17697         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17698         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17699         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
17700         return (int64_t)ret_conv;
17701 }
17702
17703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17704         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17705         CHECK_ACCESS(e_ptr);
17706         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17707         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17708         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17709         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
17710         return (int64_t)ret_conv;
17711 }
17712
17713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17714         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
17715         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
17716         return ret_conv;
17717 }
17718
17719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17720         if ((_res & 1) != 0) return;
17721         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17722         CHECK_ACCESS(_res_ptr);
17723         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
17724         FREE((void*)_res);
17725         CResult__u832APIErrorZ_free(_res_conv);
17726 }
17727
17728 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
17729         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17730         *ret_conv = CResult__u832APIErrorZ_clone(arg);
17731         return (int64_t)ret_conv;
17732 }
17733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17734         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
17735         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
17736         return ret_conv;
17737 }
17738
17739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17740         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
17741         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17742         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
17743         return (int64_t)ret_conv;
17744 }
17745
17746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17747         LDKThirtyTwoBytes o_ref;
17748         CHECK((*env)->GetArrayLength(env, o) == 32);
17749         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17750         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17751         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
17752         return (int64_t)ret_conv;
17753 }
17754
17755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17756         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17757         CHECK_ACCESS(e_ptr);
17758         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17759         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17760         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17761         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
17762         return (int64_t)ret_conv;
17763 }
17764
17765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17766         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
17767         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
17768         return ret_conv;
17769 }
17770
17771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17772         if ((_res & 1) != 0) return;
17773         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17774         CHECK_ACCESS(_res_ptr);
17775         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
17776         FREE((void*)_res);
17777         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
17778 }
17779
17780 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
17781         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17782         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
17783         return (int64_t)ret_conv;
17784 }
17785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17786         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
17787         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
17788         return ret_conv;
17789 }
17790
17791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17792         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
17793         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17794         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
17795         return (int64_t)ret_conv;
17796 }
17797
17798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
17799         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17800         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
17801         return (int64_t)ret_conv;
17802 }
17803
17804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17805         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17806         CHECK_ACCESS(e_ptr);
17807         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17808         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17809         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17810         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
17811         return (int64_t)ret_conv;
17812 }
17813
17814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17815         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
17816         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
17817         return ret_conv;
17818 }
17819
17820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17821         if ((_res & 1) != 0) return;
17822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17823         CHECK_ACCESS(_res_ptr);
17824         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
17825         FREE((void*)_res);
17826         CResult_NonePaymentSendFailureZ_free(_res_conv);
17827 }
17828
17829 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
17830         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17831         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
17832         return (int64_t)ret_conv;
17833 }
17834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17835         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
17836         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
17837         return ret_conv;
17838 }
17839
17840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17841         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
17842         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17843         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
17844         return (int64_t)ret_conv;
17845 }
17846
17847 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
17848         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17849         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
17850         return ((int64_t)ret_conv);
17851 }
17852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17853         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
17854         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
17855         return ret_conv;
17856 }
17857
17858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17859         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
17860         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17861         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
17862         return ((int64_t)ret_conv);
17863 }
17864
17865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17866         LDKThirtyTwoBytes a_ref;
17867         CHECK((*env)->GetArrayLength(env, a) == 32);
17868         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17869         LDKThirtyTwoBytes b_ref;
17870         CHECK((*env)->GetArrayLength(env, b) == 32);
17871         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17872         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17873         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
17874         return ((int64_t)ret_conv);
17875 }
17876
17877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17878         if ((_res & 1) != 0) return;
17879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17880         CHECK_ACCESS(_res_ptr);
17881         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
17882         FREE((void*)_res);
17883         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
17884 }
17885
17886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17887         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17888         CHECK_ACCESS(o_ptr);
17889         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
17890         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
17891         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17892         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
17893         return (int64_t)ret_conv;
17894 }
17895
17896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17897         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17898         CHECK_ACCESS(e_ptr);
17899         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17900         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17901         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17902         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
17903         return (int64_t)ret_conv;
17904 }
17905
17906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17907         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
17908         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
17909         return ret_conv;
17910 }
17911
17912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17913         if ((_res & 1) != 0) return;
17914         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17915         CHECK_ACCESS(_res_ptr);
17916         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
17917         FREE((void*)_res);
17918         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
17919 }
17920
17921 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
17922         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17923         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
17924         return (int64_t)ret_conv;
17925 }
17926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17927         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
17928         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
17929         return ret_conv;
17930 }
17931
17932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17933         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
17934         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17935         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
17936         return (int64_t)ret_conv;
17937 }
17938
17939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17940         LDKCVec_NetAddressZ _res_constr;
17941         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17942         if (_res_constr.datalen > 0)
17943                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17944         else
17945                 _res_constr.data = NULL;
17946         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17947         for (size_t m = 0; m < _res_constr.datalen; m++) {
17948                 int64_t _res_conv_12 = _res_vals[m];
17949                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17950                 CHECK_ACCESS(_res_conv_12_ptr);
17951                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17952                 FREE((void*)_res_conv_12);
17953                 _res_constr.data[m] = _res_conv_12_conv;
17954         }
17955         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17956         CVec_NetAddressZ_free(_res_constr);
17957 }
17958
17959 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
17960         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17961         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
17962         return ((int64_t)ret_conv);
17963 }
17964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17965         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
17966         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
17967         return ret_conv;
17968 }
17969
17970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17971         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
17972         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17973         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
17974         return ((int64_t)ret_conv);
17975 }
17976
17977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17978         LDKThirtyTwoBytes a_ref;
17979         CHECK((*env)->GetArrayLength(env, a) == 32);
17980         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17981         LDKThirtyTwoBytes b_ref;
17982         CHECK((*env)->GetArrayLength(env, b) == 32);
17983         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17984         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17985         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
17986         return ((int64_t)ret_conv);
17987 }
17988
17989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17990         if ((_res & 1) != 0) return;
17991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17992         CHECK_ACCESS(_res_ptr);
17993         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
17994         FREE((void*)_res);
17995         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
17996 }
17997
17998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17999         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18000         CHECK_ACCESS(o_ptr);
18001         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
18002         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
18003         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18004         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
18005         return (int64_t)ret_conv;
18006 }
18007
18008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
18009         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18010         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
18011         return (int64_t)ret_conv;
18012 }
18013
18014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18015         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
18016         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
18017         return ret_conv;
18018 }
18019
18020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18021         if ((_res & 1) != 0) return;
18022         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18023         CHECK_ACCESS(_res_ptr);
18024         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
18025         FREE((void*)_res);
18026         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
18027 }
18028
18029 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
18030         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18031         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
18032         return (int64_t)ret_conv;
18033 }
18034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18035         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
18036         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
18037         return ret_conv;
18038 }
18039
18040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18041         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
18042         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18043         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
18044         return (int64_t)ret_conv;
18045 }
18046
18047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18048         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18049         CHECK_ACCESS(o_ptr);
18050         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
18051         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
18052         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18053         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
18054         return (int64_t)ret_conv;
18055 }
18056
18057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18058         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18059         CHECK_ACCESS(e_ptr);
18060         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18061         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18062         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18063         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
18064         return (int64_t)ret_conv;
18065 }
18066
18067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18068         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
18069         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
18070         return ret_conv;
18071 }
18072
18073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18074         if ((_res & 1) != 0) return;
18075         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18076         CHECK_ACCESS(_res_ptr);
18077         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
18078         FREE((void*)_res);
18079         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
18080 }
18081
18082 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
18083         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18084         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
18085         return (int64_t)ret_conv;
18086 }
18087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18088         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
18089         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
18090         return ret_conv;
18091 }
18092
18093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18094         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
18095         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18096         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
18097         return (int64_t)ret_conv;
18098 }
18099
18100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18101         LDKThirtyTwoBytes o_ref;
18102         CHECK((*env)->GetArrayLength(env, o) == 32);
18103         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18104         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18105         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
18106         return (int64_t)ret_conv;
18107 }
18108
18109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
18110         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18111         *ret_conv = CResult_PaymentSecretNoneZ_err();
18112         return (int64_t)ret_conv;
18113 }
18114
18115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18116         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
18117         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
18118         return ret_conv;
18119 }
18120
18121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18122         if ((_res & 1) != 0) return;
18123         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18124         CHECK_ACCESS(_res_ptr);
18125         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
18126         FREE((void*)_res);
18127         CResult_PaymentSecretNoneZ_free(_res_conv);
18128 }
18129
18130 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
18131         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18132         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
18133         return (int64_t)ret_conv;
18134 }
18135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18136         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
18137         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
18138         return ret_conv;
18139 }
18140
18141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18142         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
18143         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18144         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
18145         return (int64_t)ret_conv;
18146 }
18147
18148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18149         LDKThirtyTwoBytes o_ref;
18150         CHECK((*env)->GetArrayLength(env, o) == 32);
18151         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18152         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18153         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
18154         return (int64_t)ret_conv;
18155 }
18156
18157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18158         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18159         CHECK_ACCESS(e_ptr);
18160         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18161         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18162         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18163         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
18164         return (int64_t)ret_conv;
18165 }
18166
18167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18168         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
18169         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
18170         return ret_conv;
18171 }
18172
18173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18174         if ((_res & 1) != 0) return;
18175         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18176         CHECK_ACCESS(_res_ptr);
18177         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
18178         FREE((void*)_res);
18179         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
18180 }
18181
18182 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
18183         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18184         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
18185         return (int64_t)ret_conv;
18186 }
18187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18188         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
18189         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
18190         return ret_conv;
18191 }
18192
18193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18194         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
18195         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18196         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
18197         return (int64_t)ret_conv;
18198 }
18199
18200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18201         LDKThirtyTwoBytes o_ref;
18202         CHECK((*env)->GetArrayLength(env, o) == 32);
18203         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18204         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18205         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
18206         return (int64_t)ret_conv;
18207 }
18208
18209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18210         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18211         CHECK_ACCESS(e_ptr);
18212         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18213         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18214         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18215         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
18216         return (int64_t)ret_conv;
18217 }
18218
18219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18220         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
18221         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
18222         return ret_conv;
18223 }
18224
18225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18226         if ((_res & 1) != 0) return;
18227         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18228         CHECK_ACCESS(_res_ptr);
18229         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
18230         FREE((void*)_res);
18231         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
18232 }
18233
18234 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
18235         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18236         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
18237         return (int64_t)ret_conv;
18238 }
18239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18240         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
18241         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
18242         return ret_conv;
18243 }
18244
18245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18246         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
18247         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18248         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
18249         return (int64_t)ret_conv;
18250 }
18251
18252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18253         LDKCounterpartyForwardingInfo o_conv;
18254         o_conv.inner = (void*)(o & (~1));
18255         o_conv.is_owned = (o & 1) || (o == 0);
18256         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18257         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
18258         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18259         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
18260         return (int64_t)ret_conv;
18261 }
18262
18263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18264         LDKDecodeError e_conv;
18265         e_conv.inner = (void*)(e & (~1));
18266         e_conv.is_owned = (e & 1) || (e == 0);
18267         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18268         e_conv = DecodeError_clone(&e_conv);
18269         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18270         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
18271         return (int64_t)ret_conv;
18272 }
18273
18274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18275         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
18276         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
18277         return ret_conv;
18278 }
18279
18280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18281         if ((_res & 1) != 0) return;
18282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18283         CHECK_ACCESS(_res_ptr);
18284         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
18285         FREE((void*)_res);
18286         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
18287 }
18288
18289 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
18290         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18291         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
18292         return (int64_t)ret_conv;
18293 }
18294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18295         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
18296         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
18297         return ret_conv;
18298 }
18299
18300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18301         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
18302         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18303         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
18304         return (int64_t)ret_conv;
18305 }
18306
18307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18308         LDKChannelCounterparty o_conv;
18309         o_conv.inner = (void*)(o & (~1));
18310         o_conv.is_owned = (o & 1) || (o == 0);
18311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18312         o_conv = ChannelCounterparty_clone(&o_conv);
18313         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18314         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
18315         return (int64_t)ret_conv;
18316 }
18317
18318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18319         LDKDecodeError e_conv;
18320         e_conv.inner = (void*)(e & (~1));
18321         e_conv.is_owned = (e & 1) || (e == 0);
18322         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18323         e_conv = DecodeError_clone(&e_conv);
18324         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18325         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
18326         return (int64_t)ret_conv;
18327 }
18328
18329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18330         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
18331         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
18332         return ret_conv;
18333 }
18334
18335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18336         if ((_res & 1) != 0) return;
18337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18338         CHECK_ACCESS(_res_ptr);
18339         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
18340         FREE((void*)_res);
18341         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
18342 }
18343
18344 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
18345         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18346         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
18347         return (int64_t)ret_conv;
18348 }
18349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18350         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
18351         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
18352         return ret_conv;
18353 }
18354
18355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18356         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
18357         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18358         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
18359         return (int64_t)ret_conv;
18360 }
18361
18362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18363         LDKChannelDetails o_conv;
18364         o_conv.inner = (void*)(o & (~1));
18365         o_conv.is_owned = (o & 1) || (o == 0);
18366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18367         o_conv = ChannelDetails_clone(&o_conv);
18368         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18369         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
18370         return (int64_t)ret_conv;
18371 }
18372
18373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18374         LDKDecodeError e_conv;
18375         e_conv.inner = (void*)(e & (~1));
18376         e_conv.is_owned = (e & 1) || (e == 0);
18377         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18378         e_conv = DecodeError_clone(&e_conv);
18379         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18380         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
18381         return (int64_t)ret_conv;
18382 }
18383
18384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18385         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
18386         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
18387         return ret_conv;
18388 }
18389
18390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18391         if ((_res & 1) != 0) return;
18392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18393         CHECK_ACCESS(_res_ptr);
18394         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
18395         FREE((void*)_res);
18396         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
18397 }
18398
18399 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
18400         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18401         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
18402         return (int64_t)ret_conv;
18403 }
18404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18405         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
18406         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
18407         return ret_conv;
18408 }
18409
18410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18411         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
18412         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18413         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
18414         return (int64_t)ret_conv;
18415 }
18416
18417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18418         LDKPhantomRouteHints o_conv;
18419         o_conv.inner = (void*)(o & (~1));
18420         o_conv.is_owned = (o & 1) || (o == 0);
18421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18422         o_conv = PhantomRouteHints_clone(&o_conv);
18423         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18424         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
18425         return (int64_t)ret_conv;
18426 }
18427
18428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18429         LDKDecodeError e_conv;
18430         e_conv.inner = (void*)(e & (~1));
18431         e_conv.is_owned = (e & 1) || (e == 0);
18432         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18433         e_conv = DecodeError_clone(&e_conv);
18434         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18435         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
18436         return (int64_t)ret_conv;
18437 }
18438
18439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18440         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
18441         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
18442         return ret_conv;
18443 }
18444
18445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18446         if ((_res & 1) != 0) return;
18447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18448         CHECK_ACCESS(_res_ptr);
18449         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
18450         FREE((void*)_res);
18451         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
18452 }
18453
18454 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
18455         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18456         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
18457         return (int64_t)ret_conv;
18458 }
18459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18460         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
18461         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
18462         return ret_conv;
18463 }
18464
18465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18466         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
18467         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18468         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
18469         return (int64_t)ret_conv;
18470 }
18471
18472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18473         LDKCVec_ChannelMonitorZ _res_constr;
18474         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18475         if (_res_constr.datalen > 0)
18476                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
18477         else
18478                 _res_constr.data = NULL;
18479         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18480         for (size_t q = 0; q < _res_constr.datalen; q++) {
18481                 int64_t _res_conv_16 = _res_vals[q];
18482                 LDKChannelMonitor _res_conv_16_conv;
18483                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18484                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18485                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18486                 _res_constr.data[q] = _res_conv_16_conv;
18487         }
18488         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18489         CVec_ChannelMonitorZ_free(_res_constr);
18490 }
18491
18492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18493         LDKThirtyTwoBytes a_ref;
18494         CHECK((*env)->GetArrayLength(env, a) == 32);
18495         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18496         LDKChannelManager b_conv;
18497         b_conv.inner = (void*)(b & (~1));
18498         b_conv.is_owned = (b & 1) || (b == 0);
18499         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18500         // WARNING: we need a move here but no clone is available for LDKChannelManager
18501         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
18502         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
18503         return ((int64_t)ret_conv);
18504 }
18505
18506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18507         if ((_res & 1) != 0) return;
18508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18509         CHECK_ACCESS(_res_ptr);
18510         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
18511         FREE((void*)_res);
18512         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
18513 }
18514
18515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18516         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18517         CHECK_ACCESS(o_ptr);
18518         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
18519         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
18520         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18521         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
18522         return (int64_t)ret_conv;
18523 }
18524
18525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18526         LDKDecodeError e_conv;
18527         e_conv.inner = (void*)(e & (~1));
18528         e_conv.is_owned = (e & 1) || (e == 0);
18529         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18530         e_conv = DecodeError_clone(&e_conv);
18531         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18532         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
18533         return (int64_t)ret_conv;
18534 }
18535
18536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18537         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
18538         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
18539         return ret_conv;
18540 }
18541
18542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18543         if ((_res & 1) != 0) return;
18544         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18545         CHECK_ACCESS(_res_ptr);
18546         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
18547         FREE((void*)_res);
18548         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
18549 }
18550
18551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18552         LDKChannelConfig o_conv;
18553         o_conv.inner = (void*)(o & (~1));
18554         o_conv.is_owned = (o & 1) || (o == 0);
18555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18556         o_conv = ChannelConfig_clone(&o_conv);
18557         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18558         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
18559         return (int64_t)ret_conv;
18560 }
18561
18562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18563         LDKDecodeError e_conv;
18564         e_conv.inner = (void*)(e & (~1));
18565         e_conv.is_owned = (e & 1) || (e == 0);
18566         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18567         e_conv = DecodeError_clone(&e_conv);
18568         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18569         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
18570         return (int64_t)ret_conv;
18571 }
18572
18573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18574         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
18575         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
18576         return ret_conv;
18577 }
18578
18579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18580         if ((_res & 1) != 0) return;
18581         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18582         CHECK_ACCESS(_res_ptr);
18583         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
18584         FREE((void*)_res);
18585         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
18586 }
18587
18588 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
18589         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18590         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
18591         return (int64_t)ret_conv;
18592 }
18593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18594         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
18595         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
18596         return ret_conv;
18597 }
18598
18599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18600         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
18601         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18602         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
18603         return (int64_t)ret_conv;
18604 }
18605
18606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18607         LDKOutPoint o_conv;
18608         o_conv.inner = (void*)(o & (~1));
18609         o_conv.is_owned = (o & 1) || (o == 0);
18610         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18611         o_conv = OutPoint_clone(&o_conv);
18612         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18613         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
18614         return (int64_t)ret_conv;
18615 }
18616
18617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18618         LDKDecodeError e_conv;
18619         e_conv.inner = (void*)(e & (~1));
18620         e_conv.is_owned = (e & 1) || (e == 0);
18621         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18622         e_conv = DecodeError_clone(&e_conv);
18623         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18624         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
18625         return (int64_t)ret_conv;
18626 }
18627
18628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18629         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
18630         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
18631         return ret_conv;
18632 }
18633
18634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18635         if ((_res & 1) != 0) return;
18636         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18637         CHECK_ACCESS(_res_ptr);
18638         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
18639         FREE((void*)_res);
18640         CResult_OutPointDecodeErrorZ_free(_res_conv);
18641 }
18642
18643 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
18644         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18645         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
18646         return (int64_t)ret_conv;
18647 }
18648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18649         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
18650         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
18651         return ret_conv;
18652 }
18653
18654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18655         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
18656         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18657         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
18658         return (int64_t)ret_conv;
18659 }
18660
18661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18662         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18663         CHECK_ACCESS(o_ptr);
18664         LDKType o_conv = *(LDKType*)(o_ptr);
18665         if (o_conv.free == LDKType_JCalls_free) {
18666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18667                 LDKType_JCalls_cloned(&o_conv);
18668         }
18669         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18670         *ret_copy = COption_TypeZ_some(o_conv);
18671         int64_t ret_ref = (uintptr_t)ret_copy;
18672         return ret_ref;
18673 }
18674
18675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
18676         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18677         *ret_copy = COption_TypeZ_none();
18678         int64_t ret_ref = (uintptr_t)ret_copy;
18679         return ret_ref;
18680 }
18681
18682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18683         if ((_res & 1) != 0) return;
18684         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18685         CHECK_ACCESS(_res_ptr);
18686         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
18687         FREE((void*)_res);
18688         COption_TypeZ_free(_res_conv);
18689 }
18690
18691 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
18692         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18693         *ret_copy = COption_TypeZ_clone(arg);
18694 int64_t ret_ref = (uintptr_t)ret_copy;
18695         return ret_ref;
18696 }
18697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18698         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
18699         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
18700         return ret_conv;
18701 }
18702
18703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18704         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
18705         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18706         *ret_copy = COption_TypeZ_clone(orig_conv);
18707         int64_t ret_ref = (uintptr_t)ret_copy;
18708         return ret_ref;
18709 }
18710
18711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18712         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18713         CHECK_ACCESS(o_ptr);
18714         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
18715         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
18716         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18717         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
18718         return (int64_t)ret_conv;
18719 }
18720
18721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18722         LDKDecodeError e_conv;
18723         e_conv.inner = (void*)(e & (~1));
18724         e_conv.is_owned = (e & 1) || (e == 0);
18725         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18726         e_conv = DecodeError_clone(&e_conv);
18727         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18728         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
18729         return (int64_t)ret_conv;
18730 }
18731
18732 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18733         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
18734         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
18735         return ret_conv;
18736 }
18737
18738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18739         if ((_res & 1) != 0) return;
18740         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18741         CHECK_ACCESS(_res_ptr);
18742         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
18743         FREE((void*)_res);
18744         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
18745 }
18746
18747 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
18748         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18749         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
18750         return (int64_t)ret_conv;
18751 }
18752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18753         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
18754         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
18755         return ret_conv;
18756 }
18757
18758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18759         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
18760         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18761         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
18762         return (int64_t)ret_conv;
18763 }
18764
18765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18766         LDKThirtyTwoBytes o_ref;
18767         CHECK((*env)->GetArrayLength(env, o) == 32);
18768         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18769         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18770         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
18771         return (int64_t)ret_conv;
18772 }
18773
18774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18775         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18776         CHECK_ACCESS(e_ptr);
18777         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
18778         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
18779         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18780         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
18781         return (int64_t)ret_conv;
18782 }
18783
18784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18785         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
18786         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
18787         return ret_conv;
18788 }
18789
18790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18791         if ((_res & 1) != 0) return;
18792         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18793         CHECK_ACCESS(_res_ptr);
18794         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
18795         FREE((void*)_res);
18796         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
18797 }
18798
18799 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
18800         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18801         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
18802         return (int64_t)ret_conv;
18803 }
18804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18805         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
18806         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
18807         return ret_conv;
18808 }
18809
18810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18811         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
18812         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18813         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
18814         return (int64_t)ret_conv;
18815 }
18816
18817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
18818         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
18819         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18820         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
18821         return (int64_t)ret_conv;
18822 }
18823
18824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18825         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18826         CHECK_ACCESS(e_ptr);
18827         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
18828         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
18829         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18830         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
18831         return (int64_t)ret_conv;
18832 }
18833
18834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18835         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
18836         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
18837         return ret_conv;
18838 }
18839
18840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18841         if ((_res & 1) != 0) return;
18842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18843         CHECK_ACCESS(_res_ptr);
18844         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
18845         FREE((void*)_res);
18846         CResult_SiPrefixParseErrorZ_free(_res_conv);
18847 }
18848
18849 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
18850         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18851         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
18852         return (int64_t)ret_conv;
18853 }
18854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18855         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
18856         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
18857         return ret_conv;
18858 }
18859
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18861         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
18862         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18863         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
18864         return (int64_t)ret_conv;
18865 }
18866
18867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18868         LDKInvoice o_conv;
18869         o_conv.inner = (void*)(o & (~1));
18870         o_conv.is_owned = (o & 1) || (o == 0);
18871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18872         o_conv = Invoice_clone(&o_conv);
18873         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18874         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
18875         return (int64_t)ret_conv;
18876 }
18877
18878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18879         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18880         CHECK_ACCESS(e_ptr);
18881         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
18882         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
18883         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18884         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
18885         return (int64_t)ret_conv;
18886 }
18887
18888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18889         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
18890         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
18891         return ret_conv;
18892 }
18893
18894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18895         if ((_res & 1) != 0) return;
18896         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18897         CHECK_ACCESS(_res_ptr);
18898         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
18899         FREE((void*)_res);
18900         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
18901 }
18902
18903 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
18904         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18905         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
18906         return (int64_t)ret_conv;
18907 }
18908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18909         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
18910         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
18911         return ret_conv;
18912 }
18913
18914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18915         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
18916         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18917         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
18918         return (int64_t)ret_conv;
18919 }
18920
18921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18922         LDKSignedRawInvoice o_conv;
18923         o_conv.inner = (void*)(o & (~1));
18924         o_conv.is_owned = (o & 1) || (o == 0);
18925         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18926         o_conv = SignedRawInvoice_clone(&o_conv);
18927         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18928         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
18929         return (int64_t)ret_conv;
18930 }
18931
18932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18933         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18934         CHECK_ACCESS(e_ptr);
18935         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
18936         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
18937         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18938         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
18939         return (int64_t)ret_conv;
18940 }
18941
18942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18943         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
18944         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
18945         return ret_conv;
18946 }
18947
18948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18949         if ((_res & 1) != 0) return;
18950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18951         CHECK_ACCESS(_res_ptr);
18952         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
18953         FREE((void*)_res);
18954         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
18955 }
18956
18957 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
18958         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18959         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
18960         return (int64_t)ret_conv;
18961 }
18962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18963         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
18964         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
18965         return ret_conv;
18966 }
18967
18968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18969         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
18970         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18971         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
18972         return (int64_t)ret_conv;
18973 }
18974
18975 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
18976         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18977         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
18978         return ((int64_t)ret_conv);
18979 }
18980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18981         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
18982         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
18983         return ret_conv;
18984 }
18985
18986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18987         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
18988         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18989         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
18990         return ((int64_t)ret_conv);
18991 }
18992
18993 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) {
18994         LDKRawInvoice a_conv;
18995         a_conv.inner = (void*)(a & (~1));
18996         a_conv.is_owned = (a & 1) || (a == 0);
18997         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18998         a_conv = RawInvoice_clone(&a_conv);
18999         LDKThirtyTwoBytes b_ref;
19000         CHECK((*env)->GetArrayLength(env, b) == 32);
19001         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19002         LDKInvoiceSignature c_conv;
19003         c_conv.inner = (void*)(c & (~1));
19004         c_conv.is_owned = (c & 1) || (c == 0);
19005         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19006         c_conv = InvoiceSignature_clone(&c_conv);
19007         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
19008         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
19009         return ((int64_t)ret_conv);
19010 }
19011
19012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19013         if ((_res & 1) != 0) return;
19014         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19015         CHECK_ACCESS(_res_ptr);
19016         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
19017         FREE((void*)_res);
19018         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
19019 }
19020
19021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19022         LDKPayeePubKey o_conv;
19023         o_conv.inner = (void*)(o & (~1));
19024         o_conv.is_owned = (o & 1) || (o == 0);
19025         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19026         o_conv = PayeePubKey_clone(&o_conv);
19027         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19028         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
19029         return (int64_t)ret_conv;
19030 }
19031
19032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19033         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19034         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19035         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
19036         return (int64_t)ret_conv;
19037 }
19038
19039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19040         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
19041         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
19042         return ret_conv;
19043 }
19044
19045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19046         if ((_res & 1) != 0) return;
19047         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19048         CHECK_ACCESS(_res_ptr);
19049         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
19050         FREE((void*)_res);
19051         CResult_PayeePubKeyErrorZ_free(_res_conv);
19052 }
19053
19054 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
19055         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19056         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
19057         return (int64_t)ret_conv;
19058 }
19059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19060         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
19061         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
19062         return ret_conv;
19063 }
19064
19065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19066         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
19067         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19068         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
19069         return (int64_t)ret_conv;
19070 }
19071
19072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19073         LDKCVec_PrivateRouteZ _res_constr;
19074         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19075         if (_res_constr.datalen > 0)
19076                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
19077         else
19078                 _res_constr.data = NULL;
19079         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19080         for (size_t o = 0; o < _res_constr.datalen; o++) {
19081                 int64_t _res_conv_14 = _res_vals[o];
19082                 LDKPrivateRoute _res_conv_14_conv;
19083                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
19084                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
19085                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
19086                 _res_constr.data[o] = _res_conv_14_conv;
19087         }
19088         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19089         CVec_PrivateRouteZ_free(_res_constr);
19090 }
19091
19092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19093         LDKPositiveTimestamp o_conv;
19094         o_conv.inner = (void*)(o & (~1));
19095         o_conv.is_owned = (o & 1) || (o == 0);
19096         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19097         o_conv = PositiveTimestamp_clone(&o_conv);
19098         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19099         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
19100         return (int64_t)ret_conv;
19101 }
19102
19103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19104         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19105         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19106         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
19107         return (int64_t)ret_conv;
19108 }
19109
19110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19111         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
19112         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
19113         return ret_conv;
19114 }
19115
19116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19117         if ((_res & 1) != 0) return;
19118         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19119         CHECK_ACCESS(_res_ptr);
19120         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
19121         FREE((void*)_res);
19122         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
19123 }
19124
19125 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
19126         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19127         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
19128         return (int64_t)ret_conv;
19129 }
19130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19131         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
19132         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
19133         return ret_conv;
19134 }
19135
19136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19137         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
19138         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19139         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
19140         return (int64_t)ret_conv;
19141 }
19142
19143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
19144         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19145         *ret_conv = CResult_NoneSemanticErrorZ_ok();
19146         return (int64_t)ret_conv;
19147 }
19148
19149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19150         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19151         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19152         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
19153         return (int64_t)ret_conv;
19154 }
19155
19156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19157         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
19158         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
19159         return ret_conv;
19160 }
19161
19162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19163         if ((_res & 1) != 0) return;
19164         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19165         CHECK_ACCESS(_res_ptr);
19166         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
19167         FREE((void*)_res);
19168         CResult_NoneSemanticErrorZ_free(_res_conv);
19169 }
19170
19171 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
19172         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19173         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
19174         return (int64_t)ret_conv;
19175 }
19176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19177         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
19178         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
19179         return ret_conv;
19180 }
19181
19182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19183         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
19184         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19185         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
19186         return (int64_t)ret_conv;
19187 }
19188
19189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19190         LDKInvoice o_conv;
19191         o_conv.inner = (void*)(o & (~1));
19192         o_conv.is_owned = (o & 1) || (o == 0);
19193         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19194         o_conv = Invoice_clone(&o_conv);
19195         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19196         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
19197         return (int64_t)ret_conv;
19198 }
19199
19200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19201         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19202         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19203         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
19204         return (int64_t)ret_conv;
19205 }
19206
19207 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19208         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
19209         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
19210         return ret_conv;
19211 }
19212
19213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19214         if ((_res & 1) != 0) return;
19215         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19216         CHECK_ACCESS(_res_ptr);
19217         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
19218         FREE((void*)_res);
19219         CResult_InvoiceSemanticErrorZ_free(_res_conv);
19220 }
19221
19222 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
19223         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19224         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
19225         return (int64_t)ret_conv;
19226 }
19227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19228         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
19229         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
19230         return ret_conv;
19231 }
19232
19233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19234         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
19235         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19236         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
19237         return (int64_t)ret_conv;
19238 }
19239
19240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19241         LDKDescription o_conv;
19242         o_conv.inner = (void*)(o & (~1));
19243         o_conv.is_owned = (o & 1) || (o == 0);
19244         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19245         o_conv = Description_clone(&o_conv);
19246         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19247         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
19248         return (int64_t)ret_conv;
19249 }
19250
19251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19252         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19253         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19254         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
19255         return (int64_t)ret_conv;
19256 }
19257
19258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19259         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
19260         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
19261         return ret_conv;
19262 }
19263
19264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19265         if ((_res & 1) != 0) return;
19266         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19267         CHECK_ACCESS(_res_ptr);
19268         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
19269         FREE((void*)_res);
19270         CResult_DescriptionCreationErrorZ_free(_res_conv);
19271 }
19272
19273 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
19274         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19275         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
19276         return (int64_t)ret_conv;
19277 }
19278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19279         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
19280         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
19281         return ret_conv;
19282 }
19283
19284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19285         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
19286         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19287         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
19288         return (int64_t)ret_conv;
19289 }
19290
19291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19292         LDKPrivateRoute o_conv;
19293         o_conv.inner = (void*)(o & (~1));
19294         o_conv.is_owned = (o & 1) || (o == 0);
19295         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19296         o_conv = PrivateRoute_clone(&o_conv);
19297         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19298         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
19299         return (int64_t)ret_conv;
19300 }
19301
19302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19303         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19304         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19305         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
19306         return (int64_t)ret_conv;
19307 }
19308
19309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19310         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
19311         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
19312         return ret_conv;
19313 }
19314
19315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19316         if ((_res & 1) != 0) return;
19317         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19318         CHECK_ACCESS(_res_ptr);
19319         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
19320         FREE((void*)_res);
19321         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
19322 }
19323
19324 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
19325         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19326         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
19327         return (int64_t)ret_conv;
19328 }
19329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19330         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
19331         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
19332         return ret_conv;
19333 }
19334
19335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19336         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
19337         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19338         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
19339         return (int64_t)ret_conv;
19340 }
19341
19342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
19343         LDKStr o_conv = java_to_owned_str(env, o);
19344         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19345         *ret_conv = CResult_StringErrorZ_ok(o_conv);
19346         return (int64_t)ret_conv;
19347 }
19348
19349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19350         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19351         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19352         *ret_conv = CResult_StringErrorZ_err(e_conv);
19353         return (int64_t)ret_conv;
19354 }
19355
19356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19357         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
19358         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
19359         return ret_conv;
19360 }
19361
19362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19363         if ((_res & 1) != 0) return;
19364         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19365         CHECK_ACCESS(_res_ptr);
19366         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
19367         FREE((void*)_res);
19368         CResult_StringErrorZ_free(_res_conv);
19369 }
19370
19371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19372         LDKChannelMonitorUpdate o_conv;
19373         o_conv.inner = (void*)(o & (~1));
19374         o_conv.is_owned = (o & 1) || (o == 0);
19375         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19376         o_conv = ChannelMonitorUpdate_clone(&o_conv);
19377         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19378         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
19379         return (int64_t)ret_conv;
19380 }
19381
19382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19383         LDKDecodeError e_conv;
19384         e_conv.inner = (void*)(e & (~1));
19385         e_conv.is_owned = (e & 1) || (e == 0);
19386         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19387         e_conv = DecodeError_clone(&e_conv);
19388         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19389         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
19390         return (int64_t)ret_conv;
19391 }
19392
19393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19394         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
19395         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
19396         return ret_conv;
19397 }
19398
19399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19400         if ((_res & 1) != 0) return;
19401         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19402         CHECK_ACCESS(_res_ptr);
19403         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
19404         FREE((void*)_res);
19405         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
19406 }
19407
19408 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
19409         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19410         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
19411         return (int64_t)ret_conv;
19412 }
19413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19414         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
19415         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
19416         return ret_conv;
19417 }
19418
19419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19420         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
19421         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19422         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
19423         return (int64_t)ret_conv;
19424 }
19425
19426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19427         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19428         CHECK_ACCESS(o_ptr);
19429         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
19430         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
19431         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19432         *ret_copy = COption_MonitorEventZ_some(o_conv);
19433         int64_t ret_ref = (uintptr_t)ret_copy;
19434         return ret_ref;
19435 }
19436
19437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
19438         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19439         *ret_copy = COption_MonitorEventZ_none();
19440         int64_t ret_ref = (uintptr_t)ret_copy;
19441         return ret_ref;
19442 }
19443
19444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19445         if ((_res & 1) != 0) return;
19446         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19447         CHECK_ACCESS(_res_ptr);
19448         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
19449         FREE((void*)_res);
19450         COption_MonitorEventZ_free(_res_conv);
19451 }
19452
19453 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
19454         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19455         *ret_copy = COption_MonitorEventZ_clone(arg);
19456 int64_t ret_ref = (uintptr_t)ret_copy;
19457         return ret_ref;
19458 }
19459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19460         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
19461         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
19462         return ret_conv;
19463 }
19464
19465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19466         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
19467         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19468         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
19469         int64_t ret_ref = (uintptr_t)ret_copy;
19470         return ret_ref;
19471 }
19472
19473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19474         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19475         CHECK_ACCESS(o_ptr);
19476         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
19477         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
19478         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19479         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
19480         return (int64_t)ret_conv;
19481 }
19482
19483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19484         LDKDecodeError e_conv;
19485         e_conv.inner = (void*)(e & (~1));
19486         e_conv.is_owned = (e & 1) || (e == 0);
19487         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19488         e_conv = DecodeError_clone(&e_conv);
19489         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19490         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
19491         return (int64_t)ret_conv;
19492 }
19493
19494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19495         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
19496         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
19497         return ret_conv;
19498 }
19499
19500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19501         if ((_res & 1) != 0) return;
19502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19503         CHECK_ACCESS(_res_ptr);
19504         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
19505         FREE((void*)_res);
19506         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
19507 }
19508
19509 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
19510         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19511         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
19512         return (int64_t)ret_conv;
19513 }
19514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19515         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
19516         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
19517         return ret_conv;
19518 }
19519
19520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19521         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
19522         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19523         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
19524         return (int64_t)ret_conv;
19525 }
19526
19527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19528         LDKHTLCUpdate o_conv;
19529         o_conv.inner = (void*)(o & (~1));
19530         o_conv.is_owned = (o & 1) || (o == 0);
19531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19532         o_conv = HTLCUpdate_clone(&o_conv);
19533         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19534         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
19535         return (int64_t)ret_conv;
19536 }
19537
19538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19539         LDKDecodeError e_conv;
19540         e_conv.inner = (void*)(e & (~1));
19541         e_conv.is_owned = (e & 1) || (e == 0);
19542         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19543         e_conv = DecodeError_clone(&e_conv);
19544         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19545         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
19546         return (int64_t)ret_conv;
19547 }
19548
19549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19550         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
19551         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
19552         return ret_conv;
19553 }
19554
19555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19556         if ((_res & 1) != 0) return;
19557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19558         CHECK_ACCESS(_res_ptr);
19559         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
19560         FREE((void*)_res);
19561         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
19562 }
19563
19564 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
19565         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19566         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
19567         return (int64_t)ret_conv;
19568 }
19569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19570         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
19571         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
19572         return ret_conv;
19573 }
19574
19575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19576         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
19577         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19578         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
19579         return (int64_t)ret_conv;
19580 }
19581
19582 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
19583         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19584         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
19585         return ((int64_t)ret_conv);
19586 }
19587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19588         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
19589         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
19590         return ret_conv;
19591 }
19592
19593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19594         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
19595         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19596         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
19597         return ((int64_t)ret_conv);
19598 }
19599
19600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
19601         LDKOutPoint a_conv;
19602         a_conv.inner = (void*)(a & (~1));
19603         a_conv.is_owned = (a & 1) || (a == 0);
19604         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19605         a_conv = OutPoint_clone(&a_conv);
19606         LDKCVec_u8Z b_ref;
19607         b_ref.datalen = (*env)->GetArrayLength(env, b);
19608         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19609         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19610         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19611         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
19612         return ((int64_t)ret_conv);
19613 }
19614
19615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19616         if ((_res & 1) != 0) return;
19617         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19618         CHECK_ACCESS(_res_ptr);
19619         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
19620         FREE((void*)_res);
19621         C2Tuple_OutPointScriptZ_free(_res_conv);
19622 }
19623
19624 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
19625         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19626         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
19627         return ((int64_t)ret_conv);
19628 }
19629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19630         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
19631         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
19632         return ret_conv;
19633 }
19634
19635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19636         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
19637         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19638         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
19639         return ((int64_t)ret_conv);
19640 }
19641
19642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
19643         LDKCVec_u8Z b_ref;
19644         b_ref.datalen = (*env)->GetArrayLength(env, b);
19645         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19646         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19647         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19648         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
19649         return ((int64_t)ret_conv);
19650 }
19651
19652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19653         if ((_res & 1) != 0) return;
19654         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19655         CHECK_ACCESS(_res_ptr);
19656         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
19657         FREE((void*)_res);
19658         C2Tuple_u32ScriptZ_free(_res_conv);
19659 }
19660
19661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19662         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
19663         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19664         if (_res_constr.datalen > 0)
19665                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19666         else
19667                 _res_constr.data = NULL;
19668         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19669         for (size_t v = 0; v < _res_constr.datalen; v++) {
19670                 int64_t _res_conv_21 = _res_vals[v];
19671                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
19672                 CHECK_ACCESS(_res_conv_21_ptr);
19673                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
19674                 FREE((void*)_res_conv_21);
19675                 _res_constr.data[v] = _res_conv_21_conv;
19676         }
19677         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19678         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
19679 }
19680
19681 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
19682         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19683         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
19684         return ((int64_t)ret_conv);
19685 }
19686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19687         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
19688         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
19689         return ret_conv;
19690 }
19691
19692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19693         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
19694         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19695         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
19696         return ((int64_t)ret_conv);
19697 }
19698
19699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19700         LDKThirtyTwoBytes a_ref;
19701         CHECK((*env)->GetArrayLength(env, a) == 32);
19702         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19703         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
19704         b_constr.datalen = (*env)->GetArrayLength(env, b);
19705         if (b_constr.datalen > 0)
19706                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19707         else
19708                 b_constr.data = NULL;
19709         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19710         for (size_t v = 0; v < b_constr.datalen; v++) {
19711                 int64_t b_conv_21 = b_vals[v];
19712                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
19713                 CHECK_ACCESS(b_conv_21_ptr);
19714                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
19715                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
19716                 b_constr.data[v] = b_conv_21_conv;
19717         }
19718         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19719         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19720         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
19721         return ((int64_t)ret_conv);
19722 }
19723
19724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19725         if ((_res & 1) != 0) return;
19726         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19727         CHECK_ACCESS(_res_ptr);
19728         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
19729         FREE((void*)_res);
19730         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
19731 }
19732
19733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19734         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
19735         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19736         if (_res_constr.datalen > 0)
19737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
19738         else
19739                 _res_constr.data = NULL;
19740         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19741         for (size_t o = 0; o < _res_constr.datalen; o++) {
19742                 int64_t _res_conv_40 = _res_vals[o];
19743                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
19744                 CHECK_ACCESS(_res_conv_40_ptr);
19745                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
19746                 FREE((void*)_res_conv_40);
19747                 _res_constr.data[o] = _res_conv_40_conv;
19748         }
19749         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19750         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
19751 }
19752
19753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19754         LDKCVec_EventZ _res_constr;
19755         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19756         if (_res_constr.datalen > 0)
19757                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
19758         else
19759                 _res_constr.data = NULL;
19760         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19761         for (size_t h = 0; h < _res_constr.datalen; h++) {
19762                 int64_t _res_conv_7 = _res_vals[h];
19763                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19764                 CHECK_ACCESS(_res_conv_7_ptr);
19765                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
19766                 FREE((void*)_res_conv_7);
19767                 _res_constr.data[h] = _res_conv_7_conv;
19768         }
19769         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19770         CVec_EventZ_free(_res_constr);
19771 }
19772
19773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19774         LDKCVec_TransactionZ _res_constr;
19775         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19776         if (_res_constr.datalen > 0)
19777                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
19778         else
19779                 _res_constr.data = NULL;
19780         for (size_t i = 0; i < _res_constr.datalen; i++) {
19781                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19782                 LDKTransaction _res_conv_8_ref;
19783                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19784                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
19785                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19786                 _res_conv_8_ref.data_is_owned = true;
19787                 _res_constr.data[i] = _res_conv_8_ref;
19788         }
19789         CVec_TransactionZ_free(_res_constr);
19790 }
19791
19792 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
19793         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19794         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
19795         return ((int64_t)ret_conv);
19796 }
19797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19798         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
19799         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
19800         return ret_conv;
19801 }
19802
19803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19804         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
19805         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19806         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
19807         return ((int64_t)ret_conv);
19808 }
19809
19810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
19811         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19812         CHECK_ACCESS(b_ptr);
19813         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
19814         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
19815         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19816         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
19817         return ((int64_t)ret_conv);
19818 }
19819
19820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19821         if ((_res & 1) != 0) return;
19822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19823         CHECK_ACCESS(_res_ptr);
19824         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
19825         FREE((void*)_res);
19826         C2Tuple_u32TxOutZ_free(_res_conv);
19827 }
19828
19829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19830         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
19831         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19832         if (_res_constr.datalen > 0)
19833                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19834         else
19835                 _res_constr.data = NULL;
19836         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19837         for (size_t u = 0; u < _res_constr.datalen; u++) {
19838                 int64_t _res_conv_20 = _res_vals[u];
19839                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
19840                 CHECK_ACCESS(_res_conv_20_ptr);
19841                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
19842                 FREE((void*)_res_conv_20);
19843                 _res_constr.data[u] = _res_conv_20_conv;
19844         }
19845         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19846         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
19847 }
19848
19849 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
19850         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19851         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
19852         return ((int64_t)ret_conv);
19853 }
19854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19855         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
19856         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
19857         return ret_conv;
19858 }
19859
19860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19861         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
19862         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19863         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
19864         return ((int64_t)ret_conv);
19865 }
19866
19867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19868         LDKThirtyTwoBytes a_ref;
19869         CHECK((*env)->GetArrayLength(env, a) == 32);
19870         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19871         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
19872         b_constr.datalen = (*env)->GetArrayLength(env, b);
19873         if (b_constr.datalen > 0)
19874                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19875         else
19876                 b_constr.data = NULL;
19877         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19878         for (size_t u = 0; u < b_constr.datalen; u++) {
19879                 int64_t b_conv_20 = b_vals[u];
19880                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
19881                 CHECK_ACCESS(b_conv_20_ptr);
19882                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
19883                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
19884                 b_constr.data[u] = b_conv_20_conv;
19885         }
19886         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19887         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19888         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
19889         return ((int64_t)ret_conv);
19890 }
19891
19892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19893         if ((_res & 1) != 0) return;
19894         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19895         CHECK_ACCESS(_res_ptr);
19896         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
19897         FREE((void*)_res);
19898         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
19899 }
19900
19901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19902         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
19903         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19904         if (_res_constr.datalen > 0)
19905                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
19906         else
19907                 _res_constr.data = NULL;
19908         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19909         for (size_t n = 0; n < _res_constr.datalen; n++) {
19910                 int64_t _res_conv_39 = _res_vals[n];
19911                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
19912                 CHECK_ACCESS(_res_conv_39_ptr);
19913                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
19914                 FREE((void*)_res_conv_39);
19915                 _res_constr.data[n] = _res_conv_39_conv;
19916         }
19917         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19918         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
19919 }
19920
19921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19922         LDKCVec_BalanceZ _res_constr;
19923         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19924         if (_res_constr.datalen > 0)
19925                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
19926         else
19927                 _res_constr.data = NULL;
19928         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19929         for (size_t j = 0; j < _res_constr.datalen; j++) {
19930                 int64_t _res_conv_9 = _res_vals[j];
19931                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
19932                 CHECK_ACCESS(_res_conv_9_ptr);
19933                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
19934                 FREE((void*)_res_conv_9);
19935                 _res_constr.data[j] = _res_conv_9_conv;
19936         }
19937         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19938         CVec_BalanceZ_free(_res_constr);
19939 }
19940
19941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19942         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19943         CHECK_ACCESS(o_ptr);
19944         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
19945         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
19946         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19947         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
19948         return (int64_t)ret_conv;
19949 }
19950
19951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19952         LDKDecodeError e_conv;
19953         e_conv.inner = (void*)(e & (~1));
19954         e_conv.is_owned = (e & 1) || (e == 0);
19955         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19956         e_conv = DecodeError_clone(&e_conv);
19957         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19958         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
19959         return (int64_t)ret_conv;
19960 }
19961
19962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19963         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
19964         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
19965         return ret_conv;
19966 }
19967
19968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19969         if ((_res & 1) != 0) return;
19970         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19971         CHECK_ACCESS(_res_ptr);
19972         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
19973         FREE((void*)_res);
19974         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
19975 }
19976
19977 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
19978         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19979         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
19980         return (int64_t)ret_conv;
19981 }
19982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19983         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
19984         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
19985         return ret_conv;
19986 }
19987
19988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19989         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
19990         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19991         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
19992         return (int64_t)ret_conv;
19993 }
19994
19995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19996         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19997         *ret_conv = CResult_NoneLightningErrorZ_ok();
19998         return (int64_t)ret_conv;
19999 }
20000
20001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20002         LDKLightningError e_conv;
20003         e_conv.inner = (void*)(e & (~1));
20004         e_conv.is_owned = (e & 1) || (e == 0);
20005         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20006         e_conv = LightningError_clone(&e_conv);
20007         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20008         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
20009         return (int64_t)ret_conv;
20010 }
20011
20012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20013         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
20014         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
20015         return ret_conv;
20016 }
20017
20018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20019         if ((_res & 1) != 0) return;
20020         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20021         CHECK_ACCESS(_res_ptr);
20022         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
20023         FREE((void*)_res);
20024         CResult_NoneLightningErrorZ_free(_res_conv);
20025 }
20026
20027 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
20028         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20029         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
20030         return (int64_t)ret_conv;
20031 }
20032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20033         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
20034         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
20035         return ret_conv;
20036 }
20037
20038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20039         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
20040         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20041         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
20042         return (int64_t)ret_conv;
20043 }
20044
20045 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
20046         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20047         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
20048         return ((int64_t)ret_conv);
20049 }
20050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20051         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
20052         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
20053         return ret_conv;
20054 }
20055
20056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20057         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
20058         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20059         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
20060         return ((int64_t)ret_conv);
20061 }
20062
20063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20064         LDKPublicKey a_ref;
20065         CHECK((*env)->GetArrayLength(env, a) == 33);
20066         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
20067         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
20068         CHECK_ACCESS(b_ptr);
20069         LDKType b_conv = *(LDKType*)(b_ptr);
20070         if (b_conv.free == LDKType_JCalls_free) {
20071                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20072                 LDKType_JCalls_cloned(&b_conv);
20073         }
20074         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20075         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
20076         return ((int64_t)ret_conv);
20077 }
20078
20079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20080         if ((_res & 1) != 0) return;
20081         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20082         CHECK_ACCESS(_res_ptr);
20083         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
20084         FREE((void*)_res);
20085         C2Tuple_PublicKeyTypeZ_free(_res_conv);
20086 }
20087
20088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20089         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
20090         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20091         if (_res_constr.datalen > 0)
20092                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
20093         else
20094                 _res_constr.data = NULL;
20095         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20096         for (size_t z = 0; z < _res_constr.datalen; z++) {
20097                 int64_t _res_conv_25 = _res_vals[z];
20098                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
20099                 CHECK_ACCESS(_res_conv_25_ptr);
20100                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
20101                 FREE((void*)_res_conv_25);
20102                 _res_constr.data[z] = _res_conv_25_conv;
20103         }
20104         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20105         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
20106 }
20107
20108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20109         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20110         *ret_conv = CResult_boolLightningErrorZ_ok(o);
20111         return (int64_t)ret_conv;
20112 }
20113
20114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20115         LDKLightningError e_conv;
20116         e_conv.inner = (void*)(e & (~1));
20117         e_conv.is_owned = (e & 1) || (e == 0);
20118         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20119         e_conv = LightningError_clone(&e_conv);
20120         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20121         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
20122         return (int64_t)ret_conv;
20123 }
20124
20125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20126         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
20127         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
20128         return ret_conv;
20129 }
20130
20131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20132         if ((_res & 1) != 0) return;
20133         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20134         CHECK_ACCESS(_res_ptr);
20135         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
20136         FREE((void*)_res);
20137         CResult_boolLightningErrorZ_free(_res_conv);
20138 }
20139
20140 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
20141         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20142         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
20143         return (int64_t)ret_conv;
20144 }
20145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20146         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
20147         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
20148         return ret_conv;
20149 }
20150
20151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20152         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
20153         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20154         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
20155         return (int64_t)ret_conv;
20156 }
20157
20158 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
20159         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20160         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
20161         return ((int64_t)ret_conv);
20162 }
20163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20164         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
20165         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
20166         return ret_conv;
20167 }
20168
20169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20170         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
20171         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20172         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
20173         return ((int64_t)ret_conv);
20174 }
20175
20176 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) {
20177         LDKChannelAnnouncement a_conv;
20178         a_conv.inner = (void*)(a & (~1));
20179         a_conv.is_owned = (a & 1) || (a == 0);
20180         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20181         a_conv = ChannelAnnouncement_clone(&a_conv);
20182         LDKChannelUpdate b_conv;
20183         b_conv.inner = (void*)(b & (~1));
20184         b_conv.is_owned = (b & 1) || (b == 0);
20185         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20186         b_conv = ChannelUpdate_clone(&b_conv);
20187         LDKChannelUpdate c_conv;
20188         c_conv.inner = (void*)(c & (~1));
20189         c_conv.is_owned = (c & 1) || (c == 0);
20190         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20191         c_conv = ChannelUpdate_clone(&c_conv);
20192         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20193         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
20194         return ((int64_t)ret_conv);
20195 }
20196
20197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20198         if ((_res & 1) != 0) return;
20199         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20200         CHECK_ACCESS(_res_ptr);
20201         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
20202         FREE((void*)_res);
20203         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
20204 }
20205
20206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20207         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
20208         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20209         if (_res_constr.datalen > 0)
20210                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
20211         else
20212                 _res_constr.data = NULL;
20213         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20214         for (size_t h = 0; h < _res_constr.datalen; h++) {
20215                 int64_t _res_conv_59 = _res_vals[h];
20216                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
20217                 CHECK_ACCESS(_res_conv_59_ptr);
20218                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
20219                 FREE((void*)_res_conv_59);
20220                 _res_constr.data[h] = _res_conv_59_conv;
20221         }
20222         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20223         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
20224 }
20225
20226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20227         LDKCVec_NodeAnnouncementZ _res_constr;
20228         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20229         if (_res_constr.datalen > 0)
20230                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
20231         else
20232                 _res_constr.data = NULL;
20233         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20234         for (size_t s = 0; s < _res_constr.datalen; s++) {
20235                 int64_t _res_conv_18 = _res_vals[s];
20236                 LDKNodeAnnouncement _res_conv_18_conv;
20237                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
20238                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
20239                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
20240                 _res_constr.data[s] = _res_conv_18_conv;
20241         }
20242         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20243         CVec_NodeAnnouncementZ_free(_res_constr);
20244 }
20245
20246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20247         LDKCVec_PublicKeyZ _res_constr;
20248         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20249         if (_res_constr.datalen > 0)
20250                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
20251         else
20252                 _res_constr.data = NULL;
20253         for (size_t i = 0; i < _res_constr.datalen; i++) {
20254                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20255                 LDKPublicKey _res_conv_8_ref;
20256                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
20257                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
20258                 _res_constr.data[i] = _res_conv_8_ref;
20259         }
20260         CVec_PublicKeyZ_free(_res_constr);
20261 }
20262
20263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20264         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20265         CHECK_ACCESS(o_ptr);
20266         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20267         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
20268         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20269         *ret_copy = COption_NetAddressZ_some(o_conv);
20270         int64_t ret_ref = (uintptr_t)ret_copy;
20271         return ret_ref;
20272 }
20273
20274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
20275         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20276         *ret_copy = COption_NetAddressZ_none();
20277         int64_t ret_ref = (uintptr_t)ret_copy;
20278         return ret_ref;
20279 }
20280
20281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20282         if ((_res & 1) != 0) return;
20283         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20284         CHECK_ACCESS(_res_ptr);
20285         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
20286         FREE((void*)_res);
20287         COption_NetAddressZ_free(_res_conv);
20288 }
20289
20290 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
20291         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20292         *ret_copy = COption_NetAddressZ_clone(arg);
20293 int64_t ret_ref = (uintptr_t)ret_copy;
20294         return ret_ref;
20295 }
20296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20297         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
20298         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
20299         return ret_conv;
20300 }
20301
20302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20303         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
20304         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20305         *ret_copy = COption_NetAddressZ_clone(orig_conv);
20306         int64_t ret_ref = (uintptr_t)ret_copy;
20307         return ret_ref;
20308 }
20309
20310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20311         LDKCVec_u8Z o_ref;
20312         o_ref.datalen = (*env)->GetArrayLength(env, o);
20313         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
20314         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20315         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20316         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
20317         return (int64_t)ret_conv;
20318 }
20319
20320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20321         LDKPeerHandleError e_conv;
20322         e_conv.inner = (void*)(e & (~1));
20323         e_conv.is_owned = (e & 1) || (e == 0);
20324         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20325         e_conv = PeerHandleError_clone(&e_conv);
20326         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20327         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
20328         return (int64_t)ret_conv;
20329 }
20330
20331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20332         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
20333         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
20334         return ret_conv;
20335 }
20336
20337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20338         if ((_res & 1) != 0) return;
20339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20340         CHECK_ACCESS(_res_ptr);
20341         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
20342         FREE((void*)_res);
20343         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
20344 }
20345
20346 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
20347         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20348         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
20349         return (int64_t)ret_conv;
20350 }
20351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20352         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
20353         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
20354         return ret_conv;
20355 }
20356
20357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20358         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
20359         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20360         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
20361         return (int64_t)ret_conv;
20362 }
20363
20364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
20365         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20366         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
20367         return (int64_t)ret_conv;
20368 }
20369
20370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20371         LDKPeerHandleError e_conv;
20372         e_conv.inner = (void*)(e & (~1));
20373         e_conv.is_owned = (e & 1) || (e == 0);
20374         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20375         e_conv = PeerHandleError_clone(&e_conv);
20376         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20377         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
20378         return (int64_t)ret_conv;
20379 }
20380
20381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20382         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
20383         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
20384         return ret_conv;
20385 }
20386
20387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20388         if ((_res & 1) != 0) return;
20389         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20390         CHECK_ACCESS(_res_ptr);
20391         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
20392         FREE((void*)_res);
20393         CResult_NonePeerHandleErrorZ_free(_res_conv);
20394 }
20395
20396 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
20397         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20398         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
20399         return (int64_t)ret_conv;
20400 }
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20402         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
20403         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
20404         return ret_conv;
20405 }
20406
20407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20408         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
20409         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20410         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
20411         return (int64_t)ret_conv;
20412 }
20413
20414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20415         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20416         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
20417         return (int64_t)ret_conv;
20418 }
20419
20420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20421         LDKPeerHandleError e_conv;
20422         e_conv.inner = (void*)(e & (~1));
20423         e_conv.is_owned = (e & 1) || (e == 0);
20424         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20425         e_conv = PeerHandleError_clone(&e_conv);
20426         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20427         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
20428         return (int64_t)ret_conv;
20429 }
20430
20431 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20432         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
20433         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
20434         return ret_conv;
20435 }
20436
20437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20438         if ((_res & 1) != 0) return;
20439         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20440         CHECK_ACCESS(_res_ptr);
20441         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
20442         FREE((void*)_res);
20443         CResult_boolPeerHandleErrorZ_free(_res_conv);
20444 }
20445
20446 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
20447         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20448         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
20449         return (int64_t)ret_conv;
20450 }
20451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20452         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
20453         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
20454         return ret_conv;
20455 }
20456
20457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20458         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
20459         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20460         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
20461         return (int64_t)ret_conv;
20462 }
20463
20464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20465         LDKNodeId o_conv;
20466         o_conv.inner = (void*)(o & (~1));
20467         o_conv.is_owned = (o & 1) || (o == 0);
20468         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20469         o_conv = NodeId_clone(&o_conv);
20470         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20471         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
20472         return (int64_t)ret_conv;
20473 }
20474
20475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20476         LDKDecodeError e_conv;
20477         e_conv.inner = (void*)(e & (~1));
20478         e_conv.is_owned = (e & 1) || (e == 0);
20479         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20480         e_conv = DecodeError_clone(&e_conv);
20481         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20482         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
20483         return (int64_t)ret_conv;
20484 }
20485
20486 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20487         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
20488         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
20489         return ret_conv;
20490 }
20491
20492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20493         if ((_res & 1) != 0) return;
20494         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20495         CHECK_ACCESS(_res_ptr);
20496         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
20497         FREE((void*)_res);
20498         CResult_NodeIdDecodeErrorZ_free(_res_conv);
20499 }
20500
20501 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
20502         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20503         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
20504         return (int64_t)ret_conv;
20505 }
20506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20507         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
20508         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
20509         return ret_conv;
20510 }
20511
20512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20513         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
20514         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20515         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
20516         return (int64_t)ret_conv;
20517 }
20518
20519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20520         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20521         CHECK_ACCESS(o_ptr);
20522         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
20523         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
20524         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20525         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
20526         return (int64_t)ret_conv;
20527 }
20528
20529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20530         LDKDecodeError e_conv;
20531         e_conv.inner = (void*)(e & (~1));
20532         e_conv.is_owned = (e & 1) || (e == 0);
20533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20534         e_conv = DecodeError_clone(&e_conv);
20535         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20536         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
20537         return (int64_t)ret_conv;
20538 }
20539
20540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20541         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
20542         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
20543         return ret_conv;
20544 }
20545
20546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20547         if ((_res & 1) != 0) return;
20548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20549         CHECK_ACCESS(_res_ptr);
20550         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
20551         FREE((void*)_res);
20552         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
20553 }
20554
20555 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
20556         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20557         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
20558         return (int64_t)ret_conv;
20559 }
20560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20561         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
20562         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
20563         return ret_conv;
20564 }
20565
20566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20567         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
20568         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20569         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
20570         return (int64_t)ret_conv;
20571 }
20572
20573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20574         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20575         CHECK_ACCESS(o_ptr);
20576         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
20577         if (o_conv.free == LDKAccess_JCalls_free) {
20578                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20579                 LDKAccess_JCalls_cloned(&o_conv);
20580         }
20581         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20582         *ret_copy = COption_AccessZ_some(o_conv);
20583         int64_t ret_ref = (uintptr_t)ret_copy;
20584         return ret_ref;
20585 }
20586
20587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
20588         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20589         *ret_copy = COption_AccessZ_none();
20590         int64_t ret_ref = (uintptr_t)ret_copy;
20591         return ret_ref;
20592 }
20593
20594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20595         if ((_res & 1) != 0) return;
20596         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20597         CHECK_ACCESS(_res_ptr);
20598         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
20599         FREE((void*)_res);
20600         COption_AccessZ_free(_res_conv);
20601 }
20602
20603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20604         LDKChannelUpdateInfo o_conv;
20605         o_conv.inner = (void*)(o & (~1));
20606         o_conv.is_owned = (o & 1) || (o == 0);
20607         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20608         o_conv = ChannelUpdateInfo_clone(&o_conv);
20609         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20610         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20611         return (int64_t)ret_conv;
20612 }
20613
20614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20615         LDKDecodeError e_conv;
20616         e_conv.inner = (void*)(e & (~1));
20617         e_conv.is_owned = (e & 1) || (e == 0);
20618         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20619         e_conv = DecodeError_clone(&e_conv);
20620         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20621         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20622         return (int64_t)ret_conv;
20623 }
20624
20625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20626         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
20627         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20628         return ret_conv;
20629 }
20630
20631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20632         if ((_res & 1) != 0) return;
20633         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20634         CHECK_ACCESS(_res_ptr);
20635         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20636         FREE((void*)_res);
20637         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20638 }
20639
20640 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20641         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20642         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20643         return (int64_t)ret_conv;
20644 }
20645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20646         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
20647         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20648         return ret_conv;
20649 }
20650
20651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20652         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
20653         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20654         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20655         return (int64_t)ret_conv;
20656 }
20657
20658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20659         LDKChannelInfo o_conv;
20660         o_conv.inner = (void*)(o & (~1));
20661         o_conv.is_owned = (o & 1) || (o == 0);
20662         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20663         o_conv = ChannelInfo_clone(&o_conv);
20664         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20665         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20666         return (int64_t)ret_conv;
20667 }
20668
20669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20670         LDKDecodeError e_conv;
20671         e_conv.inner = (void*)(e & (~1));
20672         e_conv.is_owned = (e & 1) || (e == 0);
20673         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20674         e_conv = DecodeError_clone(&e_conv);
20675         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20676         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20677         return (int64_t)ret_conv;
20678 }
20679
20680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20681         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
20682         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20683         return ret_conv;
20684 }
20685
20686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20687         if ((_res & 1) != 0) return;
20688         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20689         CHECK_ACCESS(_res_ptr);
20690         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20691         FREE((void*)_res);
20692         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20693 }
20694
20695 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20696         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20697         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20698         return (int64_t)ret_conv;
20699 }
20700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20701         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
20702         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20703         return ret_conv;
20704 }
20705
20706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20707         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
20708         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20709         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20710         return (int64_t)ret_conv;
20711 }
20712
20713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20714         LDKRoutingFees o_conv;
20715         o_conv.inner = (void*)(o & (~1));
20716         o_conv.is_owned = (o & 1) || (o == 0);
20717         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20718         o_conv = RoutingFees_clone(&o_conv);
20719         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20720         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20721         return (int64_t)ret_conv;
20722 }
20723
20724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20725         LDKDecodeError e_conv;
20726         e_conv.inner = (void*)(e & (~1));
20727         e_conv.is_owned = (e & 1) || (e == 0);
20728         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20729         e_conv = DecodeError_clone(&e_conv);
20730         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20731         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20732         return (int64_t)ret_conv;
20733 }
20734
20735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20736         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
20737         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20738         return ret_conv;
20739 }
20740
20741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20742         if ((_res & 1) != 0) return;
20743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20744         CHECK_ACCESS(_res_ptr);
20745         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20746         FREE((void*)_res);
20747         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20748 }
20749
20750 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20751         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20752         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20753         return (int64_t)ret_conv;
20754 }
20755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20756         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
20757         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20758         return ret_conv;
20759 }
20760
20761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20762         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
20763         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20764         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20765         return (int64_t)ret_conv;
20766 }
20767
20768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20769         LDKNodeAnnouncementInfo o_conv;
20770         o_conv.inner = (void*)(o & (~1));
20771         o_conv.is_owned = (o & 1) || (o == 0);
20772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20773         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20774         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20775         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20776         return (int64_t)ret_conv;
20777 }
20778
20779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20780         LDKDecodeError e_conv;
20781         e_conv.inner = (void*)(e & (~1));
20782         e_conv.is_owned = (e & 1) || (e == 0);
20783         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20784         e_conv = DecodeError_clone(&e_conv);
20785         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20786         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20787         return (int64_t)ret_conv;
20788 }
20789
20790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20791         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
20792         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20793         return ret_conv;
20794 }
20795
20796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20797         if ((_res & 1) != 0) return;
20798         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20799         CHECK_ACCESS(_res_ptr);
20800         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20801         FREE((void*)_res);
20802         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20803 }
20804
20805 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20806         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20807         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20808         return (int64_t)ret_conv;
20809 }
20810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20811         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
20812         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20813         return ret_conv;
20814 }
20815
20816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20817         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
20818         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20819         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20820         return (int64_t)ret_conv;
20821 }
20822
20823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20824         LDKCVec_u64Z _res_constr;
20825         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20826         if (_res_constr.datalen > 0)
20827                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20828         else
20829                 _res_constr.data = NULL;
20830         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20831         for (size_t g = 0; g < _res_constr.datalen; g++) {
20832                 int64_t _res_conv_6 = _res_vals[g];
20833                 _res_constr.data[g] = _res_conv_6;
20834         }
20835         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20836         CVec_u64Z_free(_res_constr);
20837 }
20838
20839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20840         LDKNodeInfo o_conv;
20841         o_conv.inner = (void*)(o & (~1));
20842         o_conv.is_owned = (o & 1) || (o == 0);
20843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20844         o_conv = NodeInfo_clone(&o_conv);
20845         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20846         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20847         return (int64_t)ret_conv;
20848 }
20849
20850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20851         LDKDecodeError e_conv;
20852         e_conv.inner = (void*)(e & (~1));
20853         e_conv.is_owned = (e & 1) || (e == 0);
20854         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20855         e_conv = DecodeError_clone(&e_conv);
20856         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20857         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20858         return (int64_t)ret_conv;
20859 }
20860
20861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20862         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
20863         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20864         return ret_conv;
20865 }
20866
20867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20868         if ((_res & 1) != 0) return;
20869         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20870         CHECK_ACCESS(_res_ptr);
20871         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20872         FREE((void*)_res);
20873         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20874 }
20875
20876 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20877         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20878         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20879         return (int64_t)ret_conv;
20880 }
20881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20882         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
20883         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20884         return ret_conv;
20885 }
20886
20887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20888         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
20889         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20890         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20891         return (int64_t)ret_conv;
20892 }
20893
20894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20895         LDKNetworkGraph o_conv;
20896         o_conv.inner = (void*)(o & (~1));
20897         o_conv.is_owned = (o & 1) || (o == 0);
20898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20899         o_conv = NetworkGraph_clone(&o_conv);
20900         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20901         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20902         return (int64_t)ret_conv;
20903 }
20904
20905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20906         LDKDecodeError e_conv;
20907         e_conv.inner = (void*)(e & (~1));
20908         e_conv.is_owned = (e & 1) || (e == 0);
20909         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20910         e_conv = DecodeError_clone(&e_conv);
20911         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20912         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20913         return (int64_t)ret_conv;
20914 }
20915
20916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20917         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
20918         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20919         return ret_conv;
20920 }
20921
20922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20923         if ((_res & 1) != 0) return;
20924         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20925         CHECK_ACCESS(_res_ptr);
20926         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20927         FREE((void*)_res);
20928         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20929 }
20930
20931 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
20932         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20933         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
20934         return (int64_t)ret_conv;
20935 }
20936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20937         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
20938         int64_t ret_conv = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
20939         return ret_conv;
20940 }
20941
20942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20943         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
20944         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20945         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
20946         return (int64_t)ret_conv;
20947 }
20948
20949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20950         LDKCVec_NetAddressZ o_constr;
20951         o_constr.datalen = (*env)->GetArrayLength(env, o);
20952         if (o_constr.datalen > 0)
20953                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20954         else
20955                 o_constr.data = NULL;
20956         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20957         for (size_t m = 0; m < o_constr.datalen; m++) {
20958                 int64_t o_conv_12 = o_vals[m];
20959                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
20960                 CHECK_ACCESS(o_conv_12_ptr);
20961                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20962                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
20963                 o_constr.data[m] = o_conv_12_conv;
20964         }
20965         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20966         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20967         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20968         int64_t ret_ref = (uintptr_t)ret_copy;
20969         return ret_ref;
20970 }
20971
20972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20973         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20974         *ret_copy = COption_CVec_NetAddressZZ_none();
20975         int64_t ret_ref = (uintptr_t)ret_copy;
20976         return ret_ref;
20977 }
20978
20979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20980         if ((_res & 1) != 0) return;
20981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20982         CHECK_ACCESS(_res_ptr);
20983         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20984         FREE((void*)_res);
20985         COption_CVec_NetAddressZZ_free(_res_conv);
20986 }
20987
20988 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20989         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20990         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20991 int64_t ret_ref = (uintptr_t)ret_copy;
20992         return ret_ref;
20993 }
20994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20995         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
20996         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20997         return ret_conv;
20998 }
20999
21000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21001         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
21002         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
21003         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
21004         int64_t ret_ref = (uintptr_t)ret_copy;
21005         return ret_ref;
21006 }
21007
21008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21009         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21010         CHECK_ACCESS(o_ptr);
21011         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21012         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21013         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21014         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
21015         return (int64_t)ret_conv;
21016 }
21017
21018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21019         LDKDecodeError e_conv;
21020         e_conv.inner = (void*)(e & (~1));
21021         e_conv.is_owned = (e & 1) || (e == 0);
21022         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21023         e_conv = DecodeError_clone(&e_conv);
21024         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21025         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
21026         return (int64_t)ret_conv;
21027 }
21028
21029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21030         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
21031         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
21032         return ret_conv;
21033 }
21034
21035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21036         if ((_res & 1) != 0) return;
21037         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21038         CHECK_ACCESS(_res_ptr);
21039         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
21040         FREE((void*)_res);
21041         CResult_NetAddressDecodeErrorZ_free(_res_conv);
21042 }
21043
21044 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
21045         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21046         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
21047         return (int64_t)ret_conv;
21048 }
21049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21050         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
21051         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
21052         return ret_conv;
21053 }
21054
21055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21056         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
21057         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21058         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
21059         return (int64_t)ret_conv;
21060 }
21061
21062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21063         LDKCVec_UpdateAddHTLCZ _res_constr;
21064         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21065         if (_res_constr.datalen > 0)
21066                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21067         else
21068                 _res_constr.data = NULL;
21069         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21070         for (size_t p = 0; p < _res_constr.datalen; p++) {
21071                 int64_t _res_conv_15 = _res_vals[p];
21072                 LDKUpdateAddHTLC _res_conv_15_conv;
21073                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
21074                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
21075                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
21076                 _res_constr.data[p] = _res_conv_15_conv;
21077         }
21078         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21079         CVec_UpdateAddHTLCZ_free(_res_constr);
21080 }
21081
21082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21083         LDKCVec_UpdateFulfillHTLCZ _res_constr;
21084         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21085         if (_res_constr.datalen > 0)
21086                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21087         else
21088                 _res_constr.data = NULL;
21089         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21090         for (size_t t = 0; t < _res_constr.datalen; t++) {
21091                 int64_t _res_conv_19 = _res_vals[t];
21092                 LDKUpdateFulfillHTLC _res_conv_19_conv;
21093                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
21094                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
21095                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
21096                 _res_constr.data[t] = _res_conv_19_conv;
21097         }
21098         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21099         CVec_UpdateFulfillHTLCZ_free(_res_constr);
21100 }
21101
21102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21103         LDKCVec_UpdateFailHTLCZ _res_constr;
21104         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21105         if (_res_constr.datalen > 0)
21106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21107         else
21108                 _res_constr.data = NULL;
21109         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21110         for (size_t q = 0; q < _res_constr.datalen; q++) {
21111                 int64_t _res_conv_16 = _res_vals[q];
21112                 LDKUpdateFailHTLC _res_conv_16_conv;
21113                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
21114                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
21115                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21116                 _res_constr.data[q] = _res_conv_16_conv;
21117         }
21118         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21119         CVec_UpdateFailHTLCZ_free(_res_constr);
21120 }
21121
21122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21123         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21124         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21125         if (_res_constr.datalen > 0)
21126                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21127         else
21128                 _res_constr.data = NULL;
21129         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21130         for (size_t z = 0; z < _res_constr.datalen; z++) {
21131                 int64_t _res_conv_25 = _res_vals[z];
21132                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21133                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
21134                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
21135                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21136                 _res_constr.data[z] = _res_conv_25_conv;
21137         }
21138         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21139         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21140 }
21141
21142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21143         LDKAcceptChannel o_conv;
21144         o_conv.inner = (void*)(o & (~1));
21145         o_conv.is_owned = (o & 1) || (o == 0);
21146         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21147         o_conv = AcceptChannel_clone(&o_conv);
21148         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21149         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21150         return (int64_t)ret_conv;
21151 }
21152
21153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21154         LDKDecodeError e_conv;
21155         e_conv.inner = (void*)(e & (~1));
21156         e_conv.is_owned = (e & 1) || (e == 0);
21157         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21158         e_conv = DecodeError_clone(&e_conv);
21159         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21160         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21161         return (int64_t)ret_conv;
21162 }
21163
21164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21165         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
21166         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21167         return ret_conv;
21168 }
21169
21170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21171         if ((_res & 1) != 0) return;
21172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21173         CHECK_ACCESS(_res_ptr);
21174         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21175         FREE((void*)_res);
21176         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21177 }
21178
21179 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21180         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21181         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21182         return (int64_t)ret_conv;
21183 }
21184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21185         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
21186         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21187         return ret_conv;
21188 }
21189
21190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21191         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
21192         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21193         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21194         return (int64_t)ret_conv;
21195 }
21196
21197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21198         LDKAnnouncementSignatures o_conv;
21199         o_conv.inner = (void*)(o & (~1));
21200         o_conv.is_owned = (o & 1) || (o == 0);
21201         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21202         o_conv = AnnouncementSignatures_clone(&o_conv);
21203         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21204         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21205         return (int64_t)ret_conv;
21206 }
21207
21208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21209         LDKDecodeError e_conv;
21210         e_conv.inner = (void*)(e & (~1));
21211         e_conv.is_owned = (e & 1) || (e == 0);
21212         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21213         e_conv = DecodeError_clone(&e_conv);
21214         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21215         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21216         return (int64_t)ret_conv;
21217 }
21218
21219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21220         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
21221         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21222         return ret_conv;
21223 }
21224
21225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21226         if ((_res & 1) != 0) return;
21227         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21228         CHECK_ACCESS(_res_ptr);
21229         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21230         FREE((void*)_res);
21231         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21232 }
21233
21234 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21235         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21236         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21237         return (int64_t)ret_conv;
21238 }
21239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21240         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
21241         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21242         return ret_conv;
21243 }
21244
21245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21246         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
21247         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21248         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21249         return (int64_t)ret_conv;
21250 }
21251
21252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21253         LDKChannelReestablish o_conv;
21254         o_conv.inner = (void*)(o & (~1));
21255         o_conv.is_owned = (o & 1) || (o == 0);
21256         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21257         o_conv = ChannelReestablish_clone(&o_conv);
21258         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21259         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21260         return (int64_t)ret_conv;
21261 }
21262
21263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21264         LDKDecodeError e_conv;
21265         e_conv.inner = (void*)(e & (~1));
21266         e_conv.is_owned = (e & 1) || (e == 0);
21267         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21268         e_conv = DecodeError_clone(&e_conv);
21269         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21270         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
21271         return (int64_t)ret_conv;
21272 }
21273
21274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21275         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
21276         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
21277         return ret_conv;
21278 }
21279
21280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21281         if ((_res & 1) != 0) return;
21282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21283         CHECK_ACCESS(_res_ptr);
21284         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
21285         FREE((void*)_res);
21286         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
21287 }
21288
21289 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
21290         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21291         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
21292         return (int64_t)ret_conv;
21293 }
21294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21295         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
21296         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
21297         return ret_conv;
21298 }
21299
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21301         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
21302         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21303         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
21304         return (int64_t)ret_conv;
21305 }
21306
21307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21308         LDKClosingSigned o_conv;
21309         o_conv.inner = (void*)(o & (~1));
21310         o_conv.is_owned = (o & 1) || (o == 0);
21311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21312         o_conv = ClosingSigned_clone(&o_conv);
21313         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21314         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
21315         return (int64_t)ret_conv;
21316 }
21317
21318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21319         LDKDecodeError e_conv;
21320         e_conv.inner = (void*)(e & (~1));
21321         e_conv.is_owned = (e & 1) || (e == 0);
21322         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21323         e_conv = DecodeError_clone(&e_conv);
21324         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21325         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
21326         return (int64_t)ret_conv;
21327 }
21328
21329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21330         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
21331         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
21332         return ret_conv;
21333 }
21334
21335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21336         if ((_res & 1) != 0) return;
21337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21338         CHECK_ACCESS(_res_ptr);
21339         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
21340         FREE((void*)_res);
21341         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
21342 }
21343
21344 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
21345         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21346         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
21347         return (int64_t)ret_conv;
21348 }
21349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21350         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
21351         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
21352         return ret_conv;
21353 }
21354
21355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21356         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
21357         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21358         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
21359         return (int64_t)ret_conv;
21360 }
21361
21362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21363         LDKClosingSignedFeeRange o_conv;
21364         o_conv.inner = (void*)(o & (~1));
21365         o_conv.is_owned = (o & 1) || (o == 0);
21366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21367         o_conv = ClosingSignedFeeRange_clone(&o_conv);
21368         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21369         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
21370         return (int64_t)ret_conv;
21371 }
21372
21373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21374         LDKDecodeError e_conv;
21375         e_conv.inner = (void*)(e & (~1));
21376         e_conv.is_owned = (e & 1) || (e == 0);
21377         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21378         e_conv = DecodeError_clone(&e_conv);
21379         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21380         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
21381         return (int64_t)ret_conv;
21382 }
21383
21384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21385         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
21386         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
21387         return ret_conv;
21388 }
21389
21390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21391         if ((_res & 1) != 0) return;
21392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21393         CHECK_ACCESS(_res_ptr);
21394         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
21395         FREE((void*)_res);
21396         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
21397 }
21398
21399 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
21400         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21401         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
21402         return (int64_t)ret_conv;
21403 }
21404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21405         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
21406         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
21407         return ret_conv;
21408 }
21409
21410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21411         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
21412         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21413         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
21414         return (int64_t)ret_conv;
21415 }
21416
21417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21418         LDKCommitmentSigned o_conv;
21419         o_conv.inner = (void*)(o & (~1));
21420         o_conv.is_owned = (o & 1) || (o == 0);
21421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21422         o_conv = CommitmentSigned_clone(&o_conv);
21423         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21424         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
21425         return (int64_t)ret_conv;
21426 }
21427
21428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21429         LDKDecodeError e_conv;
21430         e_conv.inner = (void*)(e & (~1));
21431         e_conv.is_owned = (e & 1) || (e == 0);
21432         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21433         e_conv = DecodeError_clone(&e_conv);
21434         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21435         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
21436         return (int64_t)ret_conv;
21437 }
21438
21439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21440         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
21441         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
21442         return ret_conv;
21443 }
21444
21445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21446         if ((_res & 1) != 0) return;
21447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21448         CHECK_ACCESS(_res_ptr);
21449         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
21450         FREE((void*)_res);
21451         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
21452 }
21453
21454 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
21455         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21456         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
21457         return (int64_t)ret_conv;
21458 }
21459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21460         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
21461         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
21462         return ret_conv;
21463 }
21464
21465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21466         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
21467         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21468         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
21469         return (int64_t)ret_conv;
21470 }
21471
21472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21473         LDKFundingCreated o_conv;
21474         o_conv.inner = (void*)(o & (~1));
21475         o_conv.is_owned = (o & 1) || (o == 0);
21476         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21477         o_conv = FundingCreated_clone(&o_conv);
21478         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21479         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
21480         return (int64_t)ret_conv;
21481 }
21482
21483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21484         LDKDecodeError e_conv;
21485         e_conv.inner = (void*)(e & (~1));
21486         e_conv.is_owned = (e & 1) || (e == 0);
21487         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21488         e_conv = DecodeError_clone(&e_conv);
21489         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21490         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
21491         return (int64_t)ret_conv;
21492 }
21493
21494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21495         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
21496         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
21497         return ret_conv;
21498 }
21499
21500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21501         if ((_res & 1) != 0) return;
21502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21503         CHECK_ACCESS(_res_ptr);
21504         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
21505         FREE((void*)_res);
21506         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
21507 }
21508
21509 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
21510         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21511         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
21512         return (int64_t)ret_conv;
21513 }
21514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21515         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
21516         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
21517         return ret_conv;
21518 }
21519
21520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21521         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
21522         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21523         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
21524         return (int64_t)ret_conv;
21525 }
21526
21527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21528         LDKFundingSigned o_conv;
21529         o_conv.inner = (void*)(o & (~1));
21530         o_conv.is_owned = (o & 1) || (o == 0);
21531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21532         o_conv = FundingSigned_clone(&o_conv);
21533         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21534         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
21535         return (int64_t)ret_conv;
21536 }
21537
21538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21539         LDKDecodeError e_conv;
21540         e_conv.inner = (void*)(e & (~1));
21541         e_conv.is_owned = (e & 1) || (e == 0);
21542         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21543         e_conv = DecodeError_clone(&e_conv);
21544         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21545         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
21546         return (int64_t)ret_conv;
21547 }
21548
21549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21550         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
21551         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
21552         return ret_conv;
21553 }
21554
21555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21556         if ((_res & 1) != 0) return;
21557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21558         CHECK_ACCESS(_res_ptr);
21559         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
21560         FREE((void*)_res);
21561         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
21562 }
21563
21564 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
21565         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21566         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
21567         return (int64_t)ret_conv;
21568 }
21569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21570         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
21571         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
21572         return ret_conv;
21573 }
21574
21575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21576         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
21577         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21578         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
21579         return (int64_t)ret_conv;
21580 }
21581
21582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21583         LDKFundingLocked o_conv;
21584         o_conv.inner = (void*)(o & (~1));
21585         o_conv.is_owned = (o & 1) || (o == 0);
21586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21587         o_conv = FundingLocked_clone(&o_conv);
21588         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21589         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
21590         return (int64_t)ret_conv;
21591 }
21592
21593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21594         LDKDecodeError e_conv;
21595         e_conv.inner = (void*)(e & (~1));
21596         e_conv.is_owned = (e & 1) || (e == 0);
21597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21598         e_conv = DecodeError_clone(&e_conv);
21599         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21600         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
21601         return (int64_t)ret_conv;
21602 }
21603
21604 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21605         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
21606         jboolean ret_conv = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
21607         return ret_conv;
21608 }
21609
21610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21611         if ((_res & 1) != 0) return;
21612         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21613         CHECK_ACCESS(_res_ptr);
21614         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
21615         FREE((void*)_res);
21616         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
21617 }
21618
21619 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
21620         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21621         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
21622         return (int64_t)ret_conv;
21623 }
21624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21625         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
21626         int64_t ret_conv = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
21627         return ret_conv;
21628 }
21629
21630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21631         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
21632         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21633         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
21634         return (int64_t)ret_conv;
21635 }
21636
21637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21638         LDKInit o_conv;
21639         o_conv.inner = (void*)(o & (~1));
21640         o_conv.is_owned = (o & 1) || (o == 0);
21641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21642         o_conv = Init_clone(&o_conv);
21643         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21644         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
21645         return (int64_t)ret_conv;
21646 }
21647
21648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21649         LDKDecodeError e_conv;
21650         e_conv.inner = (void*)(e & (~1));
21651         e_conv.is_owned = (e & 1) || (e == 0);
21652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21653         e_conv = DecodeError_clone(&e_conv);
21654         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21655         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
21656         return (int64_t)ret_conv;
21657 }
21658
21659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21660         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
21661         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
21662         return ret_conv;
21663 }
21664
21665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21666         if ((_res & 1) != 0) return;
21667         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21668         CHECK_ACCESS(_res_ptr);
21669         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
21670         FREE((void*)_res);
21671         CResult_InitDecodeErrorZ_free(_res_conv);
21672 }
21673
21674 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
21675         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21676         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
21677         return (int64_t)ret_conv;
21678 }
21679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21680         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
21681         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
21682         return ret_conv;
21683 }
21684
21685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21686         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
21687         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21688         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
21689         return (int64_t)ret_conv;
21690 }
21691
21692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21693         LDKOpenChannel o_conv;
21694         o_conv.inner = (void*)(o & (~1));
21695         o_conv.is_owned = (o & 1) || (o == 0);
21696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21697         o_conv = OpenChannel_clone(&o_conv);
21698         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21699         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
21700         return (int64_t)ret_conv;
21701 }
21702
21703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21704         LDKDecodeError e_conv;
21705         e_conv.inner = (void*)(e & (~1));
21706         e_conv.is_owned = (e & 1) || (e == 0);
21707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21708         e_conv = DecodeError_clone(&e_conv);
21709         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21710         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
21711         return (int64_t)ret_conv;
21712 }
21713
21714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21715         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
21716         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
21717         return ret_conv;
21718 }
21719
21720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21721         if ((_res & 1) != 0) return;
21722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21723         CHECK_ACCESS(_res_ptr);
21724         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
21725         FREE((void*)_res);
21726         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
21727 }
21728
21729 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
21730         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21731         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
21732         return (int64_t)ret_conv;
21733 }
21734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21735         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
21736         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
21737         return ret_conv;
21738 }
21739
21740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21741         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
21742         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21743         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
21744         return (int64_t)ret_conv;
21745 }
21746
21747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21748         LDKRevokeAndACK o_conv;
21749         o_conv.inner = (void*)(o & (~1));
21750         o_conv.is_owned = (o & 1) || (o == 0);
21751         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21752         o_conv = RevokeAndACK_clone(&o_conv);
21753         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21754         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
21755         return (int64_t)ret_conv;
21756 }
21757
21758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21759         LDKDecodeError e_conv;
21760         e_conv.inner = (void*)(e & (~1));
21761         e_conv.is_owned = (e & 1) || (e == 0);
21762         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21763         e_conv = DecodeError_clone(&e_conv);
21764         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21765         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
21766         return (int64_t)ret_conv;
21767 }
21768
21769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21770         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
21771         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
21772         return ret_conv;
21773 }
21774
21775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21776         if ((_res & 1) != 0) return;
21777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21778         CHECK_ACCESS(_res_ptr);
21779         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
21780         FREE((void*)_res);
21781         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
21782 }
21783
21784 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
21785         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21786         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
21787         return (int64_t)ret_conv;
21788 }
21789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21790         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
21791         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
21792         return ret_conv;
21793 }
21794
21795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21796         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
21797         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21798         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
21799         return (int64_t)ret_conv;
21800 }
21801
21802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21803         LDKShutdown o_conv;
21804         o_conv.inner = (void*)(o & (~1));
21805         o_conv.is_owned = (o & 1) || (o == 0);
21806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21807         o_conv = Shutdown_clone(&o_conv);
21808         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21809         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
21810         return (int64_t)ret_conv;
21811 }
21812
21813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21814         LDKDecodeError e_conv;
21815         e_conv.inner = (void*)(e & (~1));
21816         e_conv.is_owned = (e & 1) || (e == 0);
21817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21818         e_conv = DecodeError_clone(&e_conv);
21819         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21820         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
21821         return (int64_t)ret_conv;
21822 }
21823
21824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21825         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
21826         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
21827         return ret_conv;
21828 }
21829
21830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21831         if ((_res & 1) != 0) return;
21832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21833         CHECK_ACCESS(_res_ptr);
21834         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
21835         FREE((void*)_res);
21836         CResult_ShutdownDecodeErrorZ_free(_res_conv);
21837 }
21838
21839 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
21840         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21841         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
21842         return (int64_t)ret_conv;
21843 }
21844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21845         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
21846         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
21847         return ret_conv;
21848 }
21849
21850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21851         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
21852         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21853         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
21854         return (int64_t)ret_conv;
21855 }
21856
21857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21858         LDKUpdateFailHTLC o_conv;
21859         o_conv.inner = (void*)(o & (~1));
21860         o_conv.is_owned = (o & 1) || (o == 0);
21861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21862         o_conv = UpdateFailHTLC_clone(&o_conv);
21863         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21864         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
21865         return (int64_t)ret_conv;
21866 }
21867
21868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21869         LDKDecodeError e_conv;
21870         e_conv.inner = (void*)(e & (~1));
21871         e_conv.is_owned = (e & 1) || (e == 0);
21872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21873         e_conv = DecodeError_clone(&e_conv);
21874         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21875         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
21876         return (int64_t)ret_conv;
21877 }
21878
21879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21880         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
21881         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
21882         return ret_conv;
21883 }
21884
21885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21886         if ((_res & 1) != 0) return;
21887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21888         CHECK_ACCESS(_res_ptr);
21889         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
21890         FREE((void*)_res);
21891         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
21892 }
21893
21894 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
21895         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21896         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
21897         return (int64_t)ret_conv;
21898 }
21899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21900         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
21901         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
21902         return ret_conv;
21903 }
21904
21905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21906         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
21907         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21908         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
21909         return (int64_t)ret_conv;
21910 }
21911
21912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21913         LDKUpdateFailMalformedHTLC o_conv;
21914         o_conv.inner = (void*)(o & (~1));
21915         o_conv.is_owned = (o & 1) || (o == 0);
21916         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21917         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
21918         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21919         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
21920         return (int64_t)ret_conv;
21921 }
21922
21923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21924         LDKDecodeError e_conv;
21925         e_conv.inner = (void*)(e & (~1));
21926         e_conv.is_owned = (e & 1) || (e == 0);
21927         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21928         e_conv = DecodeError_clone(&e_conv);
21929         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21930         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
21931         return (int64_t)ret_conv;
21932 }
21933
21934 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21935         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
21936         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
21937         return ret_conv;
21938 }
21939
21940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21941         if ((_res & 1) != 0) return;
21942         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21943         CHECK_ACCESS(_res_ptr);
21944         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
21945         FREE((void*)_res);
21946         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
21947 }
21948
21949 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
21950         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21951         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
21952         return (int64_t)ret_conv;
21953 }
21954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21955         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
21956         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
21957         return ret_conv;
21958 }
21959
21960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21961         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
21962         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21963         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
21964         return (int64_t)ret_conv;
21965 }
21966
21967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21968         LDKUpdateFee o_conv;
21969         o_conv.inner = (void*)(o & (~1));
21970         o_conv.is_owned = (o & 1) || (o == 0);
21971         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21972         o_conv = UpdateFee_clone(&o_conv);
21973         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21974         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
21975         return (int64_t)ret_conv;
21976 }
21977
21978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21979         LDKDecodeError e_conv;
21980         e_conv.inner = (void*)(e & (~1));
21981         e_conv.is_owned = (e & 1) || (e == 0);
21982         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21983         e_conv = DecodeError_clone(&e_conv);
21984         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21985         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
21986         return (int64_t)ret_conv;
21987 }
21988
21989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21990         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
21991         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
21992         return ret_conv;
21993 }
21994
21995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21996         if ((_res & 1) != 0) return;
21997         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21998         CHECK_ACCESS(_res_ptr);
21999         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
22000         FREE((void*)_res);
22001         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
22002 }
22003
22004 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
22005         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22006         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
22007         return (int64_t)ret_conv;
22008 }
22009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22010         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
22011         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
22012         return ret_conv;
22013 }
22014
22015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22016         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
22017         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22018         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
22019         return (int64_t)ret_conv;
22020 }
22021
22022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22023         LDKUpdateFulfillHTLC o_conv;
22024         o_conv.inner = (void*)(o & (~1));
22025         o_conv.is_owned = (o & 1) || (o == 0);
22026         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22027         o_conv = UpdateFulfillHTLC_clone(&o_conv);
22028         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22029         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
22030         return (int64_t)ret_conv;
22031 }
22032
22033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22034         LDKDecodeError e_conv;
22035         e_conv.inner = (void*)(e & (~1));
22036         e_conv.is_owned = (e & 1) || (e == 0);
22037         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22038         e_conv = DecodeError_clone(&e_conv);
22039         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22040         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
22041         return (int64_t)ret_conv;
22042 }
22043
22044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22045         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
22046         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
22047         return ret_conv;
22048 }
22049
22050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22051         if ((_res & 1) != 0) return;
22052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22053         CHECK_ACCESS(_res_ptr);
22054         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
22055         FREE((void*)_res);
22056         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
22057 }
22058
22059 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
22060         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22061         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
22062         return (int64_t)ret_conv;
22063 }
22064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22065         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
22066         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
22067         return ret_conv;
22068 }
22069
22070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22071         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
22072         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22073         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
22074         return (int64_t)ret_conv;
22075 }
22076
22077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22078         LDKUpdateAddHTLC o_conv;
22079         o_conv.inner = (void*)(o & (~1));
22080         o_conv.is_owned = (o & 1) || (o == 0);
22081         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22082         o_conv = UpdateAddHTLC_clone(&o_conv);
22083         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22084         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
22085         return (int64_t)ret_conv;
22086 }
22087
22088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22089         LDKDecodeError e_conv;
22090         e_conv.inner = (void*)(e & (~1));
22091         e_conv.is_owned = (e & 1) || (e == 0);
22092         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22093         e_conv = DecodeError_clone(&e_conv);
22094         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22095         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
22096         return (int64_t)ret_conv;
22097 }
22098
22099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22100         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
22101         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
22102         return ret_conv;
22103 }
22104
22105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22106         if ((_res & 1) != 0) return;
22107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22108         CHECK_ACCESS(_res_ptr);
22109         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
22110         FREE((void*)_res);
22111         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
22112 }
22113
22114 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
22115         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22116         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
22117         return (int64_t)ret_conv;
22118 }
22119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22120         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
22121         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22122         return ret_conv;
22123 }
22124
22125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22126         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
22127         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22128         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22129         return (int64_t)ret_conv;
22130 }
22131
22132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22133         LDKPing o_conv;
22134         o_conv.inner = (void*)(o & (~1));
22135         o_conv.is_owned = (o & 1) || (o == 0);
22136         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22137         o_conv = Ping_clone(&o_conv);
22138         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22139         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22140         return (int64_t)ret_conv;
22141 }
22142
22143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22144         LDKDecodeError e_conv;
22145         e_conv.inner = (void*)(e & (~1));
22146         e_conv.is_owned = (e & 1) || (e == 0);
22147         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22148         e_conv = DecodeError_clone(&e_conv);
22149         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22150         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22151         return (int64_t)ret_conv;
22152 }
22153
22154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22155         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
22156         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
22157         return ret_conv;
22158 }
22159
22160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22161         if ((_res & 1) != 0) return;
22162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22163         CHECK_ACCESS(_res_ptr);
22164         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22165         FREE((void*)_res);
22166         CResult_PingDecodeErrorZ_free(_res_conv);
22167 }
22168
22169 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22170         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22171         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22172         return (int64_t)ret_conv;
22173 }
22174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22175         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
22176         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22177         return ret_conv;
22178 }
22179
22180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22181         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
22182         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22183         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22184         return (int64_t)ret_conv;
22185 }
22186
22187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22188         LDKPong o_conv;
22189         o_conv.inner = (void*)(o & (~1));
22190         o_conv.is_owned = (o & 1) || (o == 0);
22191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22192         o_conv = Pong_clone(&o_conv);
22193         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22194         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22195         return (int64_t)ret_conv;
22196 }
22197
22198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22199         LDKDecodeError e_conv;
22200         e_conv.inner = (void*)(e & (~1));
22201         e_conv.is_owned = (e & 1) || (e == 0);
22202         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22203         e_conv = DecodeError_clone(&e_conv);
22204         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22205         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22206         return (int64_t)ret_conv;
22207 }
22208
22209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22210         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
22211         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
22212         return ret_conv;
22213 }
22214
22215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22216         if ((_res & 1) != 0) return;
22217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22218         CHECK_ACCESS(_res_ptr);
22219         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22220         FREE((void*)_res);
22221         CResult_PongDecodeErrorZ_free(_res_conv);
22222 }
22223
22224 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22225         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22226         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22227         return (int64_t)ret_conv;
22228 }
22229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22230         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
22231         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22232         return ret_conv;
22233 }
22234
22235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22236         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
22237         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22238         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22239         return (int64_t)ret_conv;
22240 }
22241
22242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22243         LDKUnsignedChannelAnnouncement o_conv;
22244         o_conv.inner = (void*)(o & (~1));
22245         o_conv.is_owned = (o & 1) || (o == 0);
22246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22247         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22248         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22249         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22250         return (int64_t)ret_conv;
22251 }
22252
22253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22254         LDKDecodeError e_conv;
22255         e_conv.inner = (void*)(e & (~1));
22256         e_conv.is_owned = (e & 1) || (e == 0);
22257         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22258         e_conv = DecodeError_clone(&e_conv);
22259         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22260         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22261         return (int64_t)ret_conv;
22262 }
22263
22264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22265         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
22266         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22267         return ret_conv;
22268 }
22269
22270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22271         if ((_res & 1) != 0) return;
22272         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22273         CHECK_ACCESS(_res_ptr);
22274         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22275         FREE((void*)_res);
22276         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
22277 }
22278
22279 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22280         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22281         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
22282         return (int64_t)ret_conv;
22283 }
22284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22285         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22286         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22287         return ret_conv;
22288 }
22289
22290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22291         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22292         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22293         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22294         return (int64_t)ret_conv;
22295 }
22296
22297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22298         LDKChannelAnnouncement o_conv;
22299         o_conv.inner = (void*)(o & (~1));
22300         o_conv.is_owned = (o & 1) || (o == 0);
22301         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22302         o_conv = ChannelAnnouncement_clone(&o_conv);
22303         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22304         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
22305         return (int64_t)ret_conv;
22306 }
22307
22308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22309         LDKDecodeError e_conv;
22310         e_conv.inner = (void*)(e & (~1));
22311         e_conv.is_owned = (e & 1) || (e == 0);
22312         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22313         e_conv = DecodeError_clone(&e_conv);
22314         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22315         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
22316         return (int64_t)ret_conv;
22317 }
22318
22319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22320         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
22321         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22322         return ret_conv;
22323 }
22324
22325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22326         if ((_res & 1) != 0) return;
22327         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22328         CHECK_ACCESS(_res_ptr);
22329         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22330         FREE((void*)_res);
22331         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
22332 }
22333
22334 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22335         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22336         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
22337         return (int64_t)ret_conv;
22338 }
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22340         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22341         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22342         return ret_conv;
22343 }
22344
22345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22346         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22347         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22348         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22349         return (int64_t)ret_conv;
22350 }
22351
22352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22353         LDKUnsignedChannelUpdate o_conv;
22354         o_conv.inner = (void*)(o & (~1));
22355         o_conv.is_owned = (o & 1) || (o == 0);
22356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22357         o_conv = UnsignedChannelUpdate_clone(&o_conv);
22358         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22359         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
22360         return (int64_t)ret_conv;
22361 }
22362
22363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22364         LDKDecodeError e_conv;
22365         e_conv.inner = (void*)(e & (~1));
22366         e_conv.is_owned = (e & 1) || (e == 0);
22367         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22368         e_conv = DecodeError_clone(&e_conv);
22369         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22370         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
22371         return (int64_t)ret_conv;
22372 }
22373
22374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22375         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
22376         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
22377         return ret_conv;
22378 }
22379
22380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22381         if ((_res & 1) != 0) return;
22382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22383         CHECK_ACCESS(_res_ptr);
22384         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
22385         FREE((void*)_res);
22386         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
22387 }
22388
22389 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22390         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22391         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
22392         return (int64_t)ret_conv;
22393 }
22394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22395         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
22396         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22397         return ret_conv;
22398 }
22399
22400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22401         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
22402         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22403         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
22404         return (int64_t)ret_conv;
22405 }
22406
22407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22408         LDKChannelUpdate o_conv;
22409         o_conv.inner = (void*)(o & (~1));
22410         o_conv.is_owned = (o & 1) || (o == 0);
22411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22412         o_conv = ChannelUpdate_clone(&o_conv);
22413         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22414         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
22415         return (int64_t)ret_conv;
22416 }
22417
22418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22419         LDKDecodeError e_conv;
22420         e_conv.inner = (void*)(e & (~1));
22421         e_conv.is_owned = (e & 1) || (e == 0);
22422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22423         e_conv = DecodeError_clone(&e_conv);
22424         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22425         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
22426         return (int64_t)ret_conv;
22427 }
22428
22429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22430         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
22431         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
22432         return ret_conv;
22433 }
22434
22435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22436         if ((_res & 1) != 0) return;
22437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22438         CHECK_ACCESS(_res_ptr);
22439         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
22440         FREE((void*)_res);
22441         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
22442 }
22443
22444 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22445         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22446         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
22447         return (int64_t)ret_conv;
22448 }
22449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22450         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
22451         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22452         return ret_conv;
22453 }
22454
22455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22456         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
22457         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22458         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
22459         return (int64_t)ret_conv;
22460 }
22461
22462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22463         LDKErrorMessage o_conv;
22464         o_conv.inner = (void*)(o & (~1));
22465         o_conv.is_owned = (o & 1) || (o == 0);
22466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22467         o_conv = ErrorMessage_clone(&o_conv);
22468         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22469         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
22470         return (int64_t)ret_conv;
22471 }
22472
22473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22474         LDKDecodeError e_conv;
22475         e_conv.inner = (void*)(e & (~1));
22476         e_conv.is_owned = (e & 1) || (e == 0);
22477         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22478         e_conv = DecodeError_clone(&e_conv);
22479         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22480         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
22481         return (int64_t)ret_conv;
22482 }
22483
22484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22485         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
22486         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
22487         return ret_conv;
22488 }
22489
22490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22491         if ((_res & 1) != 0) return;
22492         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22493         CHECK_ACCESS(_res_ptr);
22494         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
22495         FREE((void*)_res);
22496         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
22497 }
22498
22499 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
22500         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22501         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
22502         return (int64_t)ret_conv;
22503 }
22504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22505         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
22506         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
22507         return ret_conv;
22508 }
22509
22510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22511         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
22512         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22513         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
22514         return (int64_t)ret_conv;
22515 }
22516
22517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22518         LDKWarningMessage o_conv;
22519         o_conv.inner = (void*)(o & (~1));
22520         o_conv.is_owned = (o & 1) || (o == 0);
22521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22522         o_conv = WarningMessage_clone(&o_conv);
22523         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22524         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
22525         return (int64_t)ret_conv;
22526 }
22527
22528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22529         LDKDecodeError e_conv;
22530         e_conv.inner = (void*)(e & (~1));
22531         e_conv.is_owned = (e & 1) || (e == 0);
22532         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22533         e_conv = DecodeError_clone(&e_conv);
22534         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22535         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
22536         return (int64_t)ret_conv;
22537 }
22538
22539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22540         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
22541         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
22542         return ret_conv;
22543 }
22544
22545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22546         if ((_res & 1) != 0) return;
22547         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22548         CHECK_ACCESS(_res_ptr);
22549         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
22550         FREE((void*)_res);
22551         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
22552 }
22553
22554 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
22555         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22556         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
22557         return (int64_t)ret_conv;
22558 }
22559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22560         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
22561         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
22562         return ret_conv;
22563 }
22564
22565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22566         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
22567         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22568         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
22569         return (int64_t)ret_conv;
22570 }
22571
22572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22573         LDKUnsignedNodeAnnouncement o_conv;
22574         o_conv.inner = (void*)(o & (~1));
22575         o_conv.is_owned = (o & 1) || (o == 0);
22576         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22577         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
22578         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22579         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
22580         return (int64_t)ret_conv;
22581 }
22582
22583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22584         LDKDecodeError e_conv;
22585         e_conv.inner = (void*)(e & (~1));
22586         e_conv.is_owned = (e & 1) || (e == 0);
22587         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22588         e_conv = DecodeError_clone(&e_conv);
22589         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22590         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
22591         return (int64_t)ret_conv;
22592 }
22593
22594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22595         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
22596         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22597         return ret_conv;
22598 }
22599
22600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22601         if ((_res & 1) != 0) return;
22602         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22603         CHECK_ACCESS(_res_ptr);
22604         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
22605         FREE((void*)_res);
22606         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
22607 }
22608
22609 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22610         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22611         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
22612         return (int64_t)ret_conv;
22613 }
22614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22615         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
22616         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22617         return ret_conv;
22618 }
22619
22620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22621         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
22622         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22623         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
22624         return (int64_t)ret_conv;
22625 }
22626
22627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22628         LDKNodeAnnouncement o_conv;
22629         o_conv.inner = (void*)(o & (~1));
22630         o_conv.is_owned = (o & 1) || (o == 0);
22631         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22632         o_conv = NodeAnnouncement_clone(&o_conv);
22633         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22634         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
22635         return (int64_t)ret_conv;
22636 }
22637
22638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22639         LDKDecodeError e_conv;
22640         e_conv.inner = (void*)(e & (~1));
22641         e_conv.is_owned = (e & 1) || (e == 0);
22642         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22643         e_conv = DecodeError_clone(&e_conv);
22644         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22645         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
22646         return (int64_t)ret_conv;
22647 }
22648
22649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22650         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
22651         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22652         return ret_conv;
22653 }
22654
22655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22656         if ((_res & 1) != 0) return;
22657         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22658         CHECK_ACCESS(_res_ptr);
22659         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
22660         FREE((void*)_res);
22661         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
22662 }
22663
22664 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22665         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22666         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
22667         return (int64_t)ret_conv;
22668 }
22669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22670         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
22671         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22672         return ret_conv;
22673 }
22674
22675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22676         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
22677         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22678         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
22679         return (int64_t)ret_conv;
22680 }
22681
22682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22683         LDKQueryShortChannelIds o_conv;
22684         o_conv.inner = (void*)(o & (~1));
22685         o_conv.is_owned = (o & 1) || (o == 0);
22686         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22687         o_conv = QueryShortChannelIds_clone(&o_conv);
22688         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22689         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
22690         return (int64_t)ret_conv;
22691 }
22692
22693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22694         LDKDecodeError e_conv;
22695         e_conv.inner = (void*)(e & (~1));
22696         e_conv.is_owned = (e & 1) || (e == 0);
22697         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22698         e_conv = DecodeError_clone(&e_conv);
22699         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22700         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
22701         return (int64_t)ret_conv;
22702 }
22703
22704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22705         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
22706         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
22707         return ret_conv;
22708 }
22709
22710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22711         if ((_res & 1) != 0) return;
22712         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22713         CHECK_ACCESS(_res_ptr);
22714         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
22715         FREE((void*)_res);
22716         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
22717 }
22718
22719 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
22720         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22721         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
22722         return (int64_t)ret_conv;
22723 }
22724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22725         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
22726         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
22727         return ret_conv;
22728 }
22729
22730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22731         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
22732         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22733         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
22734         return (int64_t)ret_conv;
22735 }
22736
22737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22738         LDKReplyShortChannelIdsEnd o_conv;
22739         o_conv.inner = (void*)(o & (~1));
22740         o_conv.is_owned = (o & 1) || (o == 0);
22741         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22742         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
22743         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22744         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
22745         return (int64_t)ret_conv;
22746 }
22747
22748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22749         LDKDecodeError e_conv;
22750         e_conv.inner = (void*)(e & (~1));
22751         e_conv.is_owned = (e & 1) || (e == 0);
22752         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22753         e_conv = DecodeError_clone(&e_conv);
22754         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22755         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
22756         return (int64_t)ret_conv;
22757 }
22758
22759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22760         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
22761         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
22762         return ret_conv;
22763 }
22764
22765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22766         if ((_res & 1) != 0) return;
22767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22768         CHECK_ACCESS(_res_ptr);
22769         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
22770         FREE((void*)_res);
22771         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
22772 }
22773
22774 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
22775         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22776         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
22777         return (int64_t)ret_conv;
22778 }
22779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22780         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
22781         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
22782         return ret_conv;
22783 }
22784
22785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22786         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
22787         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22788         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
22789         return (int64_t)ret_conv;
22790 }
22791
22792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22793         LDKQueryChannelRange o_conv;
22794         o_conv.inner = (void*)(o & (~1));
22795         o_conv.is_owned = (o & 1) || (o == 0);
22796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22797         o_conv = QueryChannelRange_clone(&o_conv);
22798         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22799         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
22800         return (int64_t)ret_conv;
22801 }
22802
22803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22804         LDKDecodeError e_conv;
22805         e_conv.inner = (void*)(e & (~1));
22806         e_conv.is_owned = (e & 1) || (e == 0);
22807         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22808         e_conv = DecodeError_clone(&e_conv);
22809         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22810         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
22811         return (int64_t)ret_conv;
22812 }
22813
22814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22815         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
22816         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
22817         return ret_conv;
22818 }
22819
22820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22821         if ((_res & 1) != 0) return;
22822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22823         CHECK_ACCESS(_res_ptr);
22824         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
22825         FREE((void*)_res);
22826         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
22827 }
22828
22829 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22830         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22831         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
22832         return (int64_t)ret_conv;
22833 }
22834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22835         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
22836         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22837         return ret_conv;
22838 }
22839
22840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22841         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
22842         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22843         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
22844         return (int64_t)ret_conv;
22845 }
22846
22847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22848         LDKReplyChannelRange o_conv;
22849         o_conv.inner = (void*)(o & (~1));
22850         o_conv.is_owned = (o & 1) || (o == 0);
22851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22852         o_conv = ReplyChannelRange_clone(&o_conv);
22853         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22854         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
22855         return (int64_t)ret_conv;
22856 }
22857
22858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22859         LDKDecodeError e_conv;
22860         e_conv.inner = (void*)(e & (~1));
22861         e_conv.is_owned = (e & 1) || (e == 0);
22862         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22863         e_conv = DecodeError_clone(&e_conv);
22864         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22865         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
22866         return (int64_t)ret_conv;
22867 }
22868
22869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22870         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
22871         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
22872         return ret_conv;
22873 }
22874
22875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22876         if ((_res & 1) != 0) return;
22877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22878         CHECK_ACCESS(_res_ptr);
22879         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
22880         FREE((void*)_res);
22881         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
22882 }
22883
22884 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22885         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22886         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
22887         return (int64_t)ret_conv;
22888 }
22889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22890         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
22891         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22892         return ret_conv;
22893 }
22894
22895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22896         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
22897         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22898         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
22899         return (int64_t)ret_conv;
22900 }
22901
22902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22903         LDKGossipTimestampFilter o_conv;
22904         o_conv.inner = (void*)(o & (~1));
22905         o_conv.is_owned = (o & 1) || (o == 0);
22906         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22907         o_conv = GossipTimestampFilter_clone(&o_conv);
22908         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22909         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
22910         return (int64_t)ret_conv;
22911 }
22912
22913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22914         LDKDecodeError e_conv;
22915         e_conv.inner = (void*)(e & (~1));
22916         e_conv.is_owned = (e & 1) || (e == 0);
22917         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22918         e_conv = DecodeError_clone(&e_conv);
22919         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22920         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
22921         return (int64_t)ret_conv;
22922 }
22923
22924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22925         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
22926         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
22927         return ret_conv;
22928 }
22929
22930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22931         if ((_res & 1) != 0) return;
22932         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22933         CHECK_ACCESS(_res_ptr);
22934         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
22935         FREE((void*)_res);
22936         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
22937 }
22938
22939 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
22940         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22941         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
22942         return (int64_t)ret_conv;
22943 }
22944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22945         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
22946         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
22947         return ret_conv;
22948 }
22949
22950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22951         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
22952         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22953         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
22954         return (int64_t)ret_conv;
22955 }
22956
22957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22958         LDKCVec_PhantomRouteHintsZ _res_constr;
22959         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22960         if (_res_constr.datalen > 0)
22961                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
22962         else
22963                 _res_constr.data = NULL;
22964         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22965         for (size_t t = 0; t < _res_constr.datalen; t++) {
22966                 int64_t _res_conv_19 = _res_vals[t];
22967                 LDKPhantomRouteHints _res_conv_19_conv;
22968                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22969                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22970                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22971                 _res_constr.data[t] = _res_conv_19_conv;
22972         }
22973         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22974         CVec_PhantomRouteHintsZ_free(_res_constr);
22975 }
22976
22977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22978         LDKInvoice o_conv;
22979         o_conv.inner = (void*)(o & (~1));
22980         o_conv.is_owned = (o & 1) || (o == 0);
22981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22982         o_conv = Invoice_clone(&o_conv);
22983         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22984         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
22985         return (int64_t)ret_conv;
22986 }
22987
22988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22989         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22990         CHECK_ACCESS(e_ptr);
22991         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
22992         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
22993         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22994         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
22995         return (int64_t)ret_conv;
22996 }
22997
22998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22999         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
23000         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
23001         return ret_conv;
23002 }
23003
23004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23005         if ((_res & 1) != 0) return;
23006         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23007         CHECK_ACCESS(_res_ptr);
23008         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
23009         FREE((void*)_res);
23010         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
23011 }
23012
23013 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
23014         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23015         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
23016         return (int64_t)ret_conv;
23017 }
23018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23019         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
23020         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
23021         return ret_conv;
23022 }
23023
23024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23025         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
23026         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23027         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
23028         return (int64_t)ret_conv;
23029 }
23030
23031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23032         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
23033         CHECK_ACCESS(o_ptr);
23034         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
23035         if (o_conv.free == LDKFilter_JCalls_free) {
23036                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23037                 LDKFilter_JCalls_cloned(&o_conv);
23038         }
23039         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23040         *ret_copy = COption_FilterZ_some(o_conv);
23041         int64_t ret_ref = (uintptr_t)ret_copy;
23042         return ret_ref;
23043 }
23044
23045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
23046         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23047         *ret_copy = COption_FilterZ_none();
23048         int64_t ret_ref = (uintptr_t)ret_copy;
23049         return ret_ref;
23050 }
23051
23052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23053         if ((_res & 1) != 0) return;
23054         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23055         CHECK_ACCESS(_res_ptr);
23056         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
23057         FREE((void*)_res);
23058         COption_FilterZ_free(_res_conv);
23059 }
23060
23061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23062         LDKLockedChannelMonitor o_conv;
23063         o_conv.inner = (void*)(o & (~1));
23064         o_conv.is_owned = (o & 1) || (o == 0);
23065         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23066         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
23067         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23068         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
23069         return (int64_t)ret_conv;
23070 }
23071
23072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
23073         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23074         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
23075         return (int64_t)ret_conv;
23076 }
23077
23078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23079         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
23080         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
23081         return ret_conv;
23082 }
23083
23084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23085         if ((_res & 1) != 0) return;
23086         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23087         CHECK_ACCESS(_res_ptr);
23088         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
23089         FREE((void*)_res);
23090         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
23091 }
23092
23093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23094         LDKCVec_OutPointZ _res_constr;
23095         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23096         if (_res_constr.datalen > 0)
23097                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
23098         else
23099                 _res_constr.data = NULL;
23100         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23101         for (size_t k = 0; k < _res_constr.datalen; k++) {
23102                 int64_t _res_conv_10 = _res_vals[k];
23103                 LDKOutPoint _res_conv_10_conv;
23104                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
23105                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
23106                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
23107                 _res_constr.data[k] = _res_conv_10_conv;
23108         }
23109         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23110         CVec_OutPointZ_free(_res_constr);
23111 }
23112
23113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23114         if ((this_ptr & 1) != 0) return;
23115         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23116         CHECK_ACCESS(this_ptr_ptr);
23117         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
23118         FREE((void*)this_ptr);
23119         PaymentPurpose_free(this_ptr_conv);
23120 }
23121
23122 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23123         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23124         *ret_copy = PaymentPurpose_clone(arg);
23125 int64_t ret_ref = (uintptr_t)ret_copy;
23126         return ret_ref;
23127 }
23128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23129         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
23130         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
23131         return ret_conv;
23132 }
23133
23134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23135         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
23136         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23137         *ret_copy = PaymentPurpose_clone(orig_conv);
23138         int64_t ret_ref = (uintptr_t)ret_copy;
23139         return ret_ref;
23140 }
23141
23142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23143         LDKThirtyTwoBytes payment_preimage_ref;
23144         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23145         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23146         LDKThirtyTwoBytes payment_secret_ref;
23147         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23148         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23149         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23150         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23151         int64_t ret_ref = (uintptr_t)ret_copy;
23152         return ret_ref;
23153 }
23154
23155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23156         LDKThirtyTwoBytes a_ref;
23157         CHECK((*env)->GetArrayLength(env, a) == 32);
23158         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23159         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23160         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23161         int64_t ret_ref = (uintptr_t)ret_copy;
23162         return ret_ref;
23163 }
23164
23165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23166         if ((this_ptr & 1) != 0) return;
23167         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23168         CHECK_ACCESS(this_ptr_ptr);
23169         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23170         FREE((void*)this_ptr);
23171         ClosureReason_free(this_ptr_conv);
23172 }
23173
23174 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23175         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23176         *ret_copy = ClosureReason_clone(arg);
23177 int64_t ret_ref = (uintptr_t)ret_copy;
23178         return ret_ref;
23179 }
23180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23181         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
23182         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
23183         return ret_conv;
23184 }
23185
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23187         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
23188         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23189         *ret_copy = ClosureReason_clone(orig_conv);
23190         int64_t ret_ref = (uintptr_t)ret_copy;
23191         return ret_ref;
23192 }
23193
23194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23195         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23196         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23197         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23198         int64_t ret_ref = (uintptr_t)ret_copy;
23199         return ret_ref;
23200 }
23201
23202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23203         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23204         *ret_copy = ClosureReason_holder_force_closed();
23205         int64_t ret_ref = (uintptr_t)ret_copy;
23206         return ret_ref;
23207 }
23208
23209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23210         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23211         *ret_copy = ClosureReason_cooperative_closure();
23212         int64_t ret_ref = (uintptr_t)ret_copy;
23213         return ret_ref;
23214 }
23215
23216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23217         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23218         *ret_copy = ClosureReason_commitment_tx_confirmed();
23219         int64_t ret_ref = (uintptr_t)ret_copy;
23220         return ret_ref;
23221 }
23222
23223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23224         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23225         *ret_copy = ClosureReason_funding_timed_out();
23226         int64_t ret_ref = (uintptr_t)ret_copy;
23227         return ret_ref;
23228 }
23229
23230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23231         LDKStr err_conv = java_to_owned_str(env, err);
23232         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23233         *ret_copy = ClosureReason_processing_error(err_conv);
23234         int64_t ret_ref = (uintptr_t)ret_copy;
23235         return ret_ref;
23236 }
23237
23238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23239         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23240         *ret_copy = ClosureReason_disconnected_peer();
23241         int64_t ret_ref = (uintptr_t)ret_copy;
23242         return ret_ref;
23243 }
23244
23245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23246         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23247         *ret_copy = ClosureReason_outdated_channel_manager();
23248         int64_t ret_ref = (uintptr_t)ret_copy;
23249         return ret_ref;
23250 }
23251
23252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
23253         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
23254         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
23255         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23256         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23257         CVec_u8Z_free(ret_var);
23258         return ret_arr;
23259 }
23260
23261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23262         LDKu8slice ser_ref;
23263         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23264         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23265         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
23266         *ret_conv = ClosureReason_read(ser_ref);
23267         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23268         return (int64_t)ret_conv;
23269 }
23270
23271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23272         if ((this_ptr & 1) != 0) return;
23273         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23274         CHECK_ACCESS(this_ptr_ptr);
23275         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
23276         FREE((void*)this_ptr);
23277         Event_free(this_ptr_conv);
23278 }
23279
23280 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
23281         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23282         *ret_copy = Event_clone(arg);
23283 int64_t ret_ref = (uintptr_t)ret_copy;
23284         return ret_ref;
23285 }
23286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23287         LDKEvent* arg_conv = (LDKEvent*)arg;
23288         int64_t ret_conv = Event_clone_ptr(arg_conv);
23289         return ret_conv;
23290 }
23291
23292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23293         LDKEvent* orig_conv = (LDKEvent*)orig;
23294         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23295         *ret_copy = Event_clone(orig_conv);
23296         int64_t ret_ref = (uintptr_t)ret_copy;
23297         return ret_ref;
23298 }
23299
23300 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) {
23301         LDKThirtyTwoBytes temporary_channel_id_ref;
23302         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23303         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23304         LDKCVec_u8Z output_script_ref;
23305         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
23306         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
23307         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
23308         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23309         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
23310         int64_t ret_ref = (uintptr_t)ret_copy;
23311         return ret_ref;
23312 }
23313
23314 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) {
23315         LDKThirtyTwoBytes payment_hash_ref;
23316         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23317         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23318         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
23319         CHECK_ACCESS(purpose_ptr);
23320         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23321         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
23322         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23323         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
23324         int64_t ret_ref = (uintptr_t)ret_copy;
23325         return ret_ref;
23326 }
23327
23328 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) {
23329         LDKThirtyTwoBytes payment_id_ref;
23330         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23331         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23332         LDKThirtyTwoBytes payment_preimage_ref;
23333         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23334         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23335         LDKThirtyTwoBytes payment_hash_ref;
23336         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23337         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23338         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
23339         CHECK_ACCESS(fee_paid_msat_ptr);
23340         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
23341         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
23342         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23343         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
23344         int64_t ret_ref = (uintptr_t)ret_copy;
23345         return ret_ref;
23346 }
23347
23348 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) {
23349         LDKThirtyTwoBytes payment_id_ref;
23350         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23351         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23352         LDKThirtyTwoBytes payment_hash_ref;
23353         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23354         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23355         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
23356         CHECK_ACCESS(network_update_ptr);
23357         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
23358         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
23359         LDKCVec_RouteHopZ path_constr;
23360         path_constr.datalen = (*env)->GetArrayLength(env, path);
23361         if (path_constr.datalen > 0)
23362                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23363         else
23364                 path_constr.data = NULL;
23365         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23366         for (size_t k = 0; k < path_constr.datalen; k++) {
23367                 int64_t path_conv_10 = path_vals[k];
23368                 LDKRouteHop path_conv_10_conv;
23369                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23370                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23371                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23372                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23373                 path_constr.data[k] = path_conv_10_conv;
23374         }
23375         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23376         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
23377         CHECK_ACCESS(short_channel_id_ptr);
23378         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
23379         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
23380         LDKRouteParameters retry_conv;
23381         retry_conv.inner = (void*)(retry & (~1));
23382         retry_conv.is_owned = (retry & 1) || (retry == 0);
23383         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
23384         retry_conv = RouteParameters_clone(&retry_conv);
23385         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23386         *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);
23387         int64_t ret_ref = (uintptr_t)ret_copy;
23388         return ret_ref;
23389 }
23390
23391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
23392         LDKThirtyTwoBytes payment_id_ref;
23393         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23394         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23395         LDKThirtyTwoBytes payment_hash_ref;
23396         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23397         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23398         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23399         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
23400         int64_t ret_ref = (uintptr_t)ret_copy;
23401         return ret_ref;
23402 }
23403
23404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
23405         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23406         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
23407         int64_t ret_ref = (uintptr_t)ret_copy;
23408         return ret_ref;
23409 }
23410
23411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
23412         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
23413         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23414         if (outputs_constr.datalen > 0)
23415                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23416         else
23417                 outputs_constr.data = NULL;
23418         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23419         for (size_t b = 0; b < outputs_constr.datalen; b++) {
23420                 int64_t outputs_conv_27 = outputs_vals[b];
23421                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
23422                 CHECK_ACCESS(outputs_conv_27_ptr);
23423                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
23424                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
23425                 outputs_constr.data[b] = outputs_conv_27_conv;
23426         }
23427         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23428         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23429         *ret_copy = Event_spendable_outputs(outputs_constr);
23430         int64_t ret_ref = (uintptr_t)ret_copy;
23431         return ret_ref;
23432 }
23433
23434 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) {
23435         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
23436         CHECK_ACCESS(fee_earned_msat_ptr);
23437         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
23438         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
23439         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23440         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
23441         int64_t ret_ref = (uintptr_t)ret_copy;
23442         return ret_ref;
23443 }
23444
23445 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) {
23446         LDKThirtyTwoBytes channel_id_ref;
23447         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23448         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23449         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
23450         CHECK_ACCESS(reason_ptr);
23451         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
23452         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
23453         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23454         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
23455         int64_t ret_ref = (uintptr_t)ret_copy;
23456         return ret_ref;
23457 }
23458
23459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
23460         LDKThirtyTwoBytes channel_id_ref;
23461         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23462         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23463         LDKTransaction transaction_ref;
23464         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
23465         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
23466         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
23467         transaction_ref.data_is_owned = true;
23468         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23469         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
23470         int64_t ret_ref = (uintptr_t)ret_copy;
23471         return ret_ref;
23472 }
23473
23474 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) {
23475         LDKThirtyTwoBytes payment_id_ref;
23476         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23477         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23478         LDKThirtyTwoBytes payment_hash_ref;
23479         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23480         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23481         LDKCVec_RouteHopZ path_constr;
23482         path_constr.datalen = (*env)->GetArrayLength(env, path);
23483         if (path_constr.datalen > 0)
23484                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23485         else
23486                 path_constr.data = NULL;
23487         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23488         for (size_t k = 0; k < path_constr.datalen; k++) {
23489                 int64_t path_conv_10 = path_vals[k];
23490                 LDKRouteHop path_conv_10_conv;
23491                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23492                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23493                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23494                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23495                 path_constr.data[k] = path_conv_10_conv;
23496         }
23497         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23498         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23499         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
23500         int64_t ret_ref = (uintptr_t)ret_copy;
23501         return ret_ref;
23502 }
23503
23504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1open_1channel_1request(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, int64_t channel_type) {
23505         LDKThirtyTwoBytes temporary_channel_id_ref;
23506         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23507         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23508         LDKPublicKey counterparty_node_id_ref;
23509         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23510         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23511         LDKChannelTypeFeatures channel_type_conv;
23512         channel_type_conv.inner = (void*)(channel_type & (~1));
23513         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
23514         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
23515         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
23516         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23517         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
23518         int64_t ret_ref = (uintptr_t)ret_copy;
23519         return ret_ref;
23520 }
23521
23522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
23523         LDKEvent* obj_conv = (LDKEvent*)obj;
23524         LDKCVec_u8Z ret_var = Event_write(obj_conv);
23525         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23526         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23527         CVec_u8Z_free(ret_var);
23528         return ret_arr;
23529 }
23530
23531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23532         LDKu8slice ser_ref;
23533         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23534         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23535         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
23536         *ret_conv = Event_read(ser_ref);
23537         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23538         return (int64_t)ret_conv;
23539 }
23540
23541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23542         if ((this_ptr & 1) != 0) return;
23543         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23544         CHECK_ACCESS(this_ptr_ptr);
23545         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
23546         FREE((void*)this_ptr);
23547         MessageSendEvent_free(this_ptr_conv);
23548 }
23549
23550 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
23551         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23552         *ret_copy = MessageSendEvent_clone(arg);
23553 int64_t ret_ref = (uintptr_t)ret_copy;
23554         return ret_ref;
23555 }
23556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23557         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
23558         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
23559         return ret_conv;
23560 }
23561
23562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23563         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
23564         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23565         *ret_copy = MessageSendEvent_clone(orig_conv);
23566         int64_t ret_ref = (uintptr_t)ret_copy;
23567         return ret_ref;
23568 }
23569
23570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23571         LDKPublicKey node_id_ref;
23572         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23573         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23574         LDKAcceptChannel msg_conv;
23575         msg_conv.inner = (void*)(msg & (~1));
23576         msg_conv.is_owned = (msg & 1) || (msg == 0);
23577         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23578         msg_conv = AcceptChannel_clone(&msg_conv);
23579         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23580         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
23581         int64_t ret_ref = (uintptr_t)ret_copy;
23582         return ret_ref;
23583 }
23584
23585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23586         LDKPublicKey node_id_ref;
23587         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23588         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23589         LDKOpenChannel msg_conv;
23590         msg_conv.inner = (void*)(msg & (~1));
23591         msg_conv.is_owned = (msg & 1) || (msg == 0);
23592         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23593         msg_conv = OpenChannel_clone(&msg_conv);
23594         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23595         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
23596         int64_t ret_ref = (uintptr_t)ret_copy;
23597         return ret_ref;
23598 }
23599
23600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23601         LDKPublicKey node_id_ref;
23602         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23603         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23604         LDKFundingCreated msg_conv;
23605         msg_conv.inner = (void*)(msg & (~1));
23606         msg_conv.is_owned = (msg & 1) || (msg == 0);
23607         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23608         msg_conv = FundingCreated_clone(&msg_conv);
23609         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23610         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
23611         int64_t ret_ref = (uintptr_t)ret_copy;
23612         return ret_ref;
23613 }
23614
23615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23616         LDKPublicKey node_id_ref;
23617         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23618         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23619         LDKFundingSigned msg_conv;
23620         msg_conv.inner = (void*)(msg & (~1));
23621         msg_conv.is_owned = (msg & 1) || (msg == 0);
23622         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23623         msg_conv = FundingSigned_clone(&msg_conv);
23624         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23625         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
23626         int64_t ret_ref = (uintptr_t)ret_copy;
23627         return ret_ref;
23628 }
23629
23630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23631         LDKPublicKey node_id_ref;
23632         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23633         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23634         LDKFundingLocked msg_conv;
23635         msg_conv.inner = (void*)(msg & (~1));
23636         msg_conv.is_owned = (msg & 1) || (msg == 0);
23637         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23638         msg_conv = FundingLocked_clone(&msg_conv);
23639         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23640         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
23641         int64_t ret_ref = (uintptr_t)ret_copy;
23642         return ret_ref;
23643 }
23644
23645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23646         LDKPublicKey node_id_ref;
23647         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23648         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23649         LDKAnnouncementSignatures msg_conv;
23650         msg_conv.inner = (void*)(msg & (~1));
23651         msg_conv.is_owned = (msg & 1) || (msg == 0);
23652         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23653         msg_conv = AnnouncementSignatures_clone(&msg_conv);
23654         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23655         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
23656         int64_t ret_ref = (uintptr_t)ret_copy;
23657         return ret_ref;
23658 }
23659
23660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
23661         LDKPublicKey node_id_ref;
23662         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23663         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23664         LDKCommitmentUpdate updates_conv;
23665         updates_conv.inner = (void*)(updates & (~1));
23666         updates_conv.is_owned = (updates & 1) || (updates == 0);
23667         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23668         updates_conv = CommitmentUpdate_clone(&updates_conv);
23669         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23670         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
23671         int64_t ret_ref = (uintptr_t)ret_copy;
23672         return ret_ref;
23673 }
23674
23675 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) {
23676         LDKPublicKey node_id_ref;
23677         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23678         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23679         LDKRevokeAndACK msg_conv;
23680         msg_conv.inner = (void*)(msg & (~1));
23681         msg_conv.is_owned = (msg & 1) || (msg == 0);
23682         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23683         msg_conv = RevokeAndACK_clone(&msg_conv);
23684         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23685         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
23686         int64_t ret_ref = (uintptr_t)ret_copy;
23687         return ret_ref;
23688 }
23689
23690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23691         LDKPublicKey node_id_ref;
23692         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23693         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23694         LDKClosingSigned msg_conv;
23695         msg_conv.inner = (void*)(msg & (~1));
23696         msg_conv.is_owned = (msg & 1) || (msg == 0);
23697         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23698         msg_conv = ClosingSigned_clone(&msg_conv);
23699         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23700         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
23701         int64_t ret_ref = (uintptr_t)ret_copy;
23702         return ret_ref;
23703 }
23704
23705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23706         LDKPublicKey node_id_ref;
23707         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23708         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23709         LDKShutdown msg_conv;
23710         msg_conv.inner = (void*)(msg & (~1));
23711         msg_conv.is_owned = (msg & 1) || (msg == 0);
23712         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23713         msg_conv = Shutdown_clone(&msg_conv);
23714         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23715         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
23716         int64_t ret_ref = (uintptr_t)ret_copy;
23717         return ret_ref;
23718 }
23719
23720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23721         LDKPublicKey node_id_ref;
23722         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23723         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23724         LDKChannelReestablish msg_conv;
23725         msg_conv.inner = (void*)(msg & (~1));
23726         msg_conv.is_owned = (msg & 1) || (msg == 0);
23727         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23728         msg_conv = ChannelReestablish_clone(&msg_conv);
23729         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23730         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
23731         int64_t ret_ref = (uintptr_t)ret_copy;
23732         return ret_ref;
23733 }
23734
23735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
23736         LDKChannelAnnouncement msg_conv;
23737         msg_conv.inner = (void*)(msg & (~1));
23738         msg_conv.is_owned = (msg & 1) || (msg == 0);
23739         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23740         msg_conv = ChannelAnnouncement_clone(&msg_conv);
23741         LDKChannelUpdate update_msg_conv;
23742         update_msg_conv.inner = (void*)(update_msg & (~1));
23743         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
23744         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
23745         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
23746         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23747         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
23748         int64_t ret_ref = (uintptr_t)ret_copy;
23749         return ret_ref;
23750 }
23751
23752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
23753         LDKNodeAnnouncement msg_conv;
23754         msg_conv.inner = (void*)(msg & (~1));
23755         msg_conv.is_owned = (msg & 1) || (msg == 0);
23756         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23757         msg_conv = NodeAnnouncement_clone(&msg_conv);
23758         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23759         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
23760         int64_t ret_ref = (uintptr_t)ret_copy;
23761         return ret_ref;
23762 }
23763
23764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
23765         LDKChannelUpdate msg_conv;
23766         msg_conv.inner = (void*)(msg & (~1));
23767         msg_conv.is_owned = (msg & 1) || (msg == 0);
23768         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23769         msg_conv = ChannelUpdate_clone(&msg_conv);
23770         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23771         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
23772         int64_t ret_ref = (uintptr_t)ret_copy;
23773         return ret_ref;
23774 }
23775
23776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23777         LDKPublicKey node_id_ref;
23778         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23779         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23780         LDKChannelUpdate msg_conv;
23781         msg_conv.inner = (void*)(msg & (~1));
23782         msg_conv.is_owned = (msg & 1) || (msg == 0);
23783         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23784         msg_conv = ChannelUpdate_clone(&msg_conv);
23785         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23786         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
23787         int64_t ret_ref = (uintptr_t)ret_copy;
23788         return ret_ref;
23789 }
23790
23791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
23792         LDKPublicKey node_id_ref;
23793         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23794         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23795         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
23796         CHECK_ACCESS(action_ptr);
23797         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
23798         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
23799         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23800         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
23801         int64_t ret_ref = (uintptr_t)ret_copy;
23802         return ret_ref;
23803 }
23804
23805 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) {
23806         LDKPublicKey node_id_ref;
23807         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23808         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23809         LDKQueryChannelRange msg_conv;
23810         msg_conv.inner = (void*)(msg & (~1));
23811         msg_conv.is_owned = (msg & 1) || (msg == 0);
23812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23813         msg_conv = QueryChannelRange_clone(&msg_conv);
23814         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23815         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
23816         int64_t ret_ref = (uintptr_t)ret_copy;
23817         return ret_ref;
23818 }
23819
23820 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) {
23821         LDKPublicKey node_id_ref;
23822         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23823         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23824         LDKQueryShortChannelIds msg_conv;
23825         msg_conv.inner = (void*)(msg & (~1));
23826         msg_conv.is_owned = (msg & 1) || (msg == 0);
23827         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23828         msg_conv = QueryShortChannelIds_clone(&msg_conv);
23829         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23830         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
23831         int64_t ret_ref = (uintptr_t)ret_copy;
23832         return ret_ref;
23833 }
23834
23835 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) {
23836         LDKPublicKey node_id_ref;
23837         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23838         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23839         LDKReplyChannelRange msg_conv;
23840         msg_conv.inner = (void*)(msg & (~1));
23841         msg_conv.is_owned = (msg & 1) || (msg == 0);
23842         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23843         msg_conv = ReplyChannelRange_clone(&msg_conv);
23844         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23845         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
23846         int64_t ret_ref = (uintptr_t)ret_copy;
23847         return ret_ref;
23848 }
23849
23850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1gossip_1timestamp_1filter(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23851         LDKPublicKey node_id_ref;
23852         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23853         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23854         LDKGossipTimestampFilter msg_conv;
23855         msg_conv.inner = (void*)(msg & (~1));
23856         msg_conv.is_owned = (msg & 1) || (msg == 0);
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23858         msg_conv = GossipTimestampFilter_clone(&msg_conv);
23859         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23860         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
23861         int64_t ret_ref = (uintptr_t)ret_copy;
23862         return ret_ref;
23863 }
23864
23865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23866         if ((this_ptr & 1) != 0) return;
23867         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23868         CHECK_ACCESS(this_ptr_ptr);
23869         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
23870         FREE((void*)this_ptr);
23871         MessageSendEventsProvider_free(this_ptr_conv);
23872 }
23873
23874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23875         if ((this_ptr & 1) != 0) return;
23876         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23877         CHECK_ACCESS(this_ptr_ptr);
23878         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
23879         FREE((void*)this_ptr);
23880         EventsProvider_free(this_ptr_conv);
23881 }
23882
23883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23884         if ((this_ptr & 1) != 0) return;
23885         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23886         CHECK_ACCESS(this_ptr_ptr);
23887         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
23888         FREE((void*)this_ptr);
23889         EventHandler_free(this_ptr_conv);
23890 }
23891
23892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23893         if ((this_ptr & 1) != 0) return;
23894         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23895         CHECK_ACCESS(this_ptr_ptr);
23896         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
23897         FREE((void*)this_ptr);
23898         APIError_free(this_ptr_conv);
23899 }
23900
23901 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
23902         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23903         *ret_copy = APIError_clone(arg);
23904 int64_t ret_ref = (uintptr_t)ret_copy;
23905         return ret_ref;
23906 }
23907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23908         LDKAPIError* arg_conv = (LDKAPIError*)arg;
23909         int64_t ret_conv = APIError_clone_ptr(arg_conv);
23910         return ret_conv;
23911 }
23912
23913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23914         LDKAPIError* orig_conv = (LDKAPIError*)orig;
23915         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23916         *ret_copy = APIError_clone(orig_conv);
23917         int64_t ret_ref = (uintptr_t)ret_copy;
23918         return ret_ref;
23919 }
23920
23921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
23922         LDKStr err_conv = java_to_owned_str(env, err);
23923         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23924         *ret_copy = APIError_apimisuse_error(err_conv);
23925         int64_t ret_ref = (uintptr_t)ret_copy;
23926         return ret_ref;
23927 }
23928
23929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
23930         LDKStr err_conv = java_to_owned_str(env, err);
23931         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23932         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
23933         int64_t ret_ref = (uintptr_t)ret_copy;
23934         return ret_ref;
23935 }
23936
23937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
23938         LDKStr err_conv = java_to_owned_str(env, err);
23939         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23940         *ret_copy = APIError_route_error(err_conv);
23941         int64_t ret_ref = (uintptr_t)ret_copy;
23942         return ret_ref;
23943 }
23944
23945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
23946         LDKStr err_conv = java_to_owned_str(env, err);
23947         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23948         *ret_copy = APIError_channel_unavailable(err_conv);
23949         int64_t ret_ref = (uintptr_t)ret_copy;
23950         return ret_ref;
23951 }
23952
23953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
23954         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23955         *ret_copy = APIError_monitor_update_failed();
23956         int64_t ret_ref = (uintptr_t)ret_copy;
23957         return ret_ref;
23958 }
23959
23960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
23961         LDKShutdownScript script_conv;
23962         script_conv.inner = (void*)(script & (~1));
23963         script_conv.is_owned = (script & 1) || (script == 0);
23964         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
23965         script_conv = ShutdownScript_clone(&script_conv);
23966         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23967         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
23968         int64_t ret_ref = (uintptr_t)ret_copy;
23969         return ret_ref;
23970 }
23971
23972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
23973         LDKu8slice msg_ref;
23974         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23975         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23976         unsigned char sk_arr[32];
23977         CHECK((*env)->GetArrayLength(env, sk) == 32);
23978         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
23979         unsigned char (*sk_ref)[32] = &sk_arr;
23980         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
23981         *ret_conv = sign(msg_ref, sk_ref);
23982         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23983         return (int64_t)ret_conv;
23984 }
23985
23986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
23987         LDKu8slice msg_ref;
23988         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23989         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23990         LDKStr sig_conv = java_to_owned_str(env, sig);
23991         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23992         *ret_conv = recover_pk(msg_ref, sig_conv);
23993         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23994         return (int64_t)ret_conv;
23995 }
23996
23997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
23998         LDKu8slice msg_ref;
23999         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24000         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24001         LDKStr sig_conv = java_to_owned_str(env, sig);
24002         LDKPublicKey pk_ref;
24003         CHECK((*env)->GetArrayLength(env, pk) == 33);
24004         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
24005         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
24006         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24007         return ret_conv;
24008 }
24009
24010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
24011         LDKu8slice hrp_bytes_ref;
24012         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
24013         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
24014         LDKCVec_u5Z data_without_signature_constr;
24015         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
24016         if (data_without_signature_constr.datalen > 0)
24017                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
24018         else
24019                 data_without_signature_constr.data = NULL;
24020         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
24021         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
24022                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
24023                 
24024                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
24025         }
24026         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
24027         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
24028         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24029         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24030         CVec_u8Z_free(ret_var);
24031         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
24032         return ret_arr;
24033 }
24034
24035 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24036         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
24037         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
24038         return ret_conv;
24039 }
24040
24041 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
24042         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
24043         return ret_conv;
24044 }
24045
24046 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
24047         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
24048         return ret_conv;
24049 }
24050
24051 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
24052         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
24053         return ret_conv;
24054 }
24055
24056 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
24057         jclass ret_conv = LDKLevel_to_java(env, Level_info());
24058         return ret_conv;
24059 }
24060
24061 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24062         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24063         return ret_conv;
24064 }
24065
24066 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24067         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24068         return ret_conv;
24069 }
24070
24071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24072         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
24073         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
24074         jboolean ret_conv = Level_eq(a_conv, b_conv);
24075         return ret_conv;
24076 }
24077
24078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24079         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
24080         int64_t ret_conv = Level_hash(o_conv);
24081         return ret_conv;
24082 }
24083
24084 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24085         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24086         return ret_conv;
24087 }
24088
24089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24090         LDKRecord this_obj_conv;
24091         this_obj_conv.inner = (void*)(this_obj & (~1));
24092         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24094         Record_free(this_obj_conv);
24095 }
24096
24097 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24098         LDKRecord this_ptr_conv;
24099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24100         this_ptr_conv.is_owned = false;
24101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24102         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24103         return ret_conv;
24104 }
24105
24106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24107         LDKRecord this_ptr_conv;
24108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24109         this_ptr_conv.is_owned = false;
24110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24111         LDKLevel val_conv = LDKLevel_from_java(env, val);
24112         Record_set_level(&this_ptr_conv, val_conv);
24113 }
24114
24115 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24116         LDKRecord this_ptr_conv;
24117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24118         this_ptr_conv.is_owned = false;
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24120         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24121         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24122         Str_free(ret_str);
24123         return ret_conv;
24124 }
24125
24126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24127         LDKRecord this_ptr_conv;
24128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24129         this_ptr_conv.is_owned = false;
24130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24131         LDKStr val_conv = java_to_owned_str(env, val);
24132         Record_set_args(&this_ptr_conv, val_conv);
24133 }
24134
24135 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24136         LDKRecord this_ptr_conv;
24137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24138         this_ptr_conv.is_owned = false;
24139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24140         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24141         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24142         Str_free(ret_str);
24143         return ret_conv;
24144 }
24145
24146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24147         LDKRecord this_ptr_conv;
24148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24149         this_ptr_conv.is_owned = false;
24150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24151         LDKStr val_conv = java_to_owned_str(env, val);
24152         Record_set_module_path(&this_ptr_conv, val_conv);
24153 }
24154
24155 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24156         LDKRecord this_ptr_conv;
24157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24158         this_ptr_conv.is_owned = false;
24159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24160         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24161         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24162         Str_free(ret_str);
24163         return ret_conv;
24164 }
24165
24166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24167         LDKRecord this_ptr_conv;
24168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24169         this_ptr_conv.is_owned = false;
24170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24171         LDKStr val_conv = java_to_owned_str(env, val);
24172         Record_set_file(&this_ptr_conv, val_conv);
24173 }
24174
24175 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24176         LDKRecord this_ptr_conv;
24177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24178         this_ptr_conv.is_owned = false;
24179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24180         int32_t ret_conv = Record_get_line(&this_ptr_conv);
24181         return ret_conv;
24182 }
24183
24184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24185         LDKRecord this_ptr_conv;
24186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24187         this_ptr_conv.is_owned = false;
24188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24189         Record_set_line(&this_ptr_conv, val);
24190 }
24191
24192 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
24193         LDKRecord ret_var = Record_clone(arg);
24194 int64_t ret_ref = 0;
24195 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24196 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24197 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24198 ret_ref = (uintptr_t)ret_var.inner;
24199 if (ret_var.is_owned) {
24200         ret_ref |= 1;
24201 }
24202         return ret_ref;
24203 }
24204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24205         LDKRecord arg_conv;
24206         arg_conv.inner = (void*)(arg & (~1));
24207         arg_conv.is_owned = false;
24208         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24209         int64_t ret_conv = Record_clone_ptr(&arg_conv);
24210         return ret_conv;
24211 }
24212
24213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24214         LDKRecord orig_conv;
24215         orig_conv.inner = (void*)(orig & (~1));
24216         orig_conv.is_owned = false;
24217         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24218         LDKRecord ret_var = Record_clone(&orig_conv);
24219         int64_t ret_ref = 0;
24220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24223         ret_ref = (uintptr_t)ret_var.inner;
24224         if (ret_var.is_owned) {
24225                 ret_ref |= 1;
24226         }
24227         return ret_ref;
24228 }
24229
24230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24231         if ((this_ptr & 1) != 0) return;
24232         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24233         CHECK_ACCESS(this_ptr_ptr);
24234         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
24235         FREE((void*)this_ptr);
24236         Logger_free(this_ptr_conv);
24237 }
24238
24239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24240         LDKChannelHandshakeConfig this_obj_conv;
24241         this_obj_conv.inner = (void*)(this_obj & (~1));
24242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24244         ChannelHandshakeConfig_free(this_obj_conv);
24245 }
24246
24247 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24248         LDKChannelHandshakeConfig this_ptr_conv;
24249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24250         this_ptr_conv.is_owned = false;
24251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24252         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
24253         return ret_conv;
24254 }
24255
24256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24257         LDKChannelHandshakeConfig this_ptr_conv;
24258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24259         this_ptr_conv.is_owned = false;
24260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24261         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
24262 }
24263
24264 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24265         LDKChannelHandshakeConfig this_ptr_conv;
24266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24267         this_ptr_conv.is_owned = false;
24268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24269         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
24270         return ret_conv;
24271 }
24272
24273 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) {
24274         LDKChannelHandshakeConfig this_ptr_conv;
24275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24276         this_ptr_conv.is_owned = false;
24277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24278         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
24279 }
24280
24281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24282         LDKChannelHandshakeConfig this_ptr_conv;
24283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24284         this_ptr_conv.is_owned = false;
24285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24286         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
24287         return ret_conv;
24288 }
24289
24290 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) {
24291         LDKChannelHandshakeConfig this_ptr_conv;
24292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24293         this_ptr_conv.is_owned = false;
24294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24295         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
24296 }
24297
24298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
24299         LDKChannelHandshakeConfig this_ptr_conv;
24300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24301         this_ptr_conv.is_owned = false;
24302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24303         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
24304         return ret_conv;
24305 }
24306
24307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24308         LDKChannelHandshakeConfig this_ptr_conv;
24309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24310         this_ptr_conv.is_owned = false;
24311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24312         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
24313 }
24314
24315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, jboolean negotiate_scid_privacy_arg) {
24316         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
24317         int64_t ret_ref = 0;
24318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24321         ret_ref = (uintptr_t)ret_var.inner;
24322         if (ret_var.is_owned) {
24323                 ret_ref |= 1;
24324         }
24325         return ret_ref;
24326 }
24327
24328 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
24329         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
24330 int64_t ret_ref = 0;
24331 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24332 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24333 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24334 ret_ref = (uintptr_t)ret_var.inner;
24335 if (ret_var.is_owned) {
24336         ret_ref |= 1;
24337 }
24338         return ret_ref;
24339 }
24340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24341         LDKChannelHandshakeConfig arg_conv;
24342         arg_conv.inner = (void*)(arg & (~1));
24343         arg_conv.is_owned = false;
24344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24345         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
24346         return ret_conv;
24347 }
24348
24349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24350         LDKChannelHandshakeConfig orig_conv;
24351         orig_conv.inner = (void*)(orig & (~1));
24352         orig_conv.is_owned = false;
24353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24354         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
24355         int64_t ret_ref = 0;
24356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24359         ret_ref = (uintptr_t)ret_var.inner;
24360         if (ret_var.is_owned) {
24361                 ret_ref |= 1;
24362         }
24363         return ret_ref;
24364 }
24365
24366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
24367         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
24368         int64_t ret_ref = 0;
24369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24372         ret_ref = (uintptr_t)ret_var.inner;
24373         if (ret_var.is_owned) {
24374                 ret_ref |= 1;
24375         }
24376         return ret_ref;
24377 }
24378
24379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24380         LDKChannelHandshakeLimits this_obj_conv;
24381         this_obj_conv.inner = (void*)(this_obj & (~1));
24382         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24384         ChannelHandshakeLimits_free(this_obj_conv);
24385 }
24386
24387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24388         LDKChannelHandshakeLimits this_ptr_conv;
24389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24390         this_ptr_conv.is_owned = false;
24391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24392         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
24393         return ret_conv;
24394 }
24395
24396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24397         LDKChannelHandshakeLimits this_ptr_conv;
24398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24399         this_ptr_conv.is_owned = false;
24400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24401         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
24402 }
24403
24404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24405         LDKChannelHandshakeLimits this_ptr_conv;
24406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24407         this_ptr_conv.is_owned = false;
24408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24409         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
24410         return ret_conv;
24411 }
24412
24413 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) {
24414         LDKChannelHandshakeLimits this_ptr_conv;
24415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24416         this_ptr_conv.is_owned = false;
24417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24418         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
24419 }
24420
24421 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) {
24422         LDKChannelHandshakeLimits this_ptr_conv;
24423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24424         this_ptr_conv.is_owned = false;
24425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24426         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
24427         return ret_conv;
24428 }
24429
24430 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) {
24431         LDKChannelHandshakeLimits this_ptr_conv;
24432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24433         this_ptr_conv.is_owned = false;
24434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24435         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
24436 }
24437
24438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24439         LDKChannelHandshakeLimits this_ptr_conv;
24440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24441         this_ptr_conv.is_owned = false;
24442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24443         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
24444         return ret_conv;
24445 }
24446
24447 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) {
24448         LDKChannelHandshakeLimits this_ptr_conv;
24449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24450         this_ptr_conv.is_owned = false;
24451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24452         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
24453 }
24454
24455 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24456         LDKChannelHandshakeLimits this_ptr_conv;
24457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24458         this_ptr_conv.is_owned = false;
24459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24460         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
24461         return ret_conv;
24462 }
24463
24464 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) {
24465         LDKChannelHandshakeLimits this_ptr_conv;
24466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24467         this_ptr_conv.is_owned = false;
24468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24469         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
24470 }
24471
24472 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24473         LDKChannelHandshakeLimits this_ptr_conv;
24474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24475         this_ptr_conv.is_owned = false;
24476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24477         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
24478         return ret_conv;
24479 }
24480
24481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24482         LDKChannelHandshakeLimits this_ptr_conv;
24483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24484         this_ptr_conv.is_owned = false;
24485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24486         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
24487 }
24488
24489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
24490         LDKChannelHandshakeLimits this_ptr_conv;
24491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24492         this_ptr_conv.is_owned = false;
24493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24494         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
24495         return ret_conv;
24496 }
24497
24498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24499         LDKChannelHandshakeLimits this_ptr_conv;
24500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24501         this_ptr_conv.is_owned = false;
24502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24503         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
24504 }
24505
24506 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24507         LDKChannelHandshakeLimits this_ptr_conv;
24508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24509         this_ptr_conv.is_owned = false;
24510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24511         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
24512         return ret_conv;
24513 }
24514
24515 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) {
24516         LDKChannelHandshakeLimits this_ptr_conv;
24517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24518         this_ptr_conv.is_owned = false;
24519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24520         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
24521 }
24522
24523 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) {
24524         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);
24525         int64_t ret_ref = 0;
24526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24529         ret_ref = (uintptr_t)ret_var.inner;
24530         if (ret_var.is_owned) {
24531                 ret_ref |= 1;
24532         }
24533         return ret_ref;
24534 }
24535
24536 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
24537         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
24538 int64_t ret_ref = 0;
24539 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24540 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24541 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24542 ret_ref = (uintptr_t)ret_var.inner;
24543 if (ret_var.is_owned) {
24544         ret_ref |= 1;
24545 }
24546         return ret_ref;
24547 }
24548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24549         LDKChannelHandshakeLimits arg_conv;
24550         arg_conv.inner = (void*)(arg & (~1));
24551         arg_conv.is_owned = false;
24552         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24553         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
24554         return ret_conv;
24555 }
24556
24557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24558         LDKChannelHandshakeLimits orig_conv;
24559         orig_conv.inner = (void*)(orig & (~1));
24560         orig_conv.is_owned = false;
24561         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24562         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
24563         int64_t ret_ref = 0;
24564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24567         ret_ref = (uintptr_t)ret_var.inner;
24568         if (ret_var.is_owned) {
24569                 ret_ref |= 1;
24570         }
24571         return ret_ref;
24572 }
24573
24574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
24575         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
24576         int64_t ret_ref = 0;
24577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24580         ret_ref = (uintptr_t)ret_var.inner;
24581         if (ret_var.is_owned) {
24582                 ret_ref |= 1;
24583         }
24584         return ret_ref;
24585 }
24586
24587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24588         LDKChannelConfig this_obj_conv;
24589         this_obj_conv.inner = (void*)(this_obj & (~1));
24590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24592         ChannelConfig_free(this_obj_conv);
24593 }
24594
24595 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24596         LDKChannelConfig this_ptr_conv;
24597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24598         this_ptr_conv.is_owned = false;
24599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24600         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
24601         return ret_conv;
24602 }
24603
24604 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) {
24605         LDKChannelConfig this_ptr_conv;
24606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24607         this_ptr_conv.is_owned = false;
24608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24609         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
24610 }
24611
24612 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24613         LDKChannelConfig this_ptr_conv;
24614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24615         this_ptr_conv.is_owned = false;
24616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24617         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
24618         return ret_conv;
24619 }
24620
24621 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) {
24622         LDKChannelConfig this_ptr_conv;
24623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24624         this_ptr_conv.is_owned = false;
24625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24626         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
24627 }
24628
24629 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24630         LDKChannelConfig this_ptr_conv;
24631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24632         this_ptr_conv.is_owned = false;
24633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24634         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
24635         return ret_conv;
24636 }
24637
24638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24639         LDKChannelConfig this_ptr_conv;
24640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24641         this_ptr_conv.is_owned = false;
24642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24643         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
24644 }
24645
24646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24647         LDKChannelConfig this_ptr_conv;
24648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24649         this_ptr_conv.is_owned = false;
24650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24651         jboolean ret_conv = ChannelConfig_get_announced_channel(&this_ptr_conv);
24652         return ret_conv;
24653 }
24654
24655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24656         LDKChannelConfig this_ptr_conv;
24657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24658         this_ptr_conv.is_owned = false;
24659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24660         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
24661 }
24662
24663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24664         LDKChannelConfig this_ptr_conv;
24665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24666         this_ptr_conv.is_owned = false;
24667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24668         jboolean ret_conv = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
24669         return ret_conv;
24670 }
24671
24672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24673         LDKChannelConfig this_ptr_conv;
24674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24675         this_ptr_conv.is_owned = false;
24676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24677         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
24678 }
24679
24680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24681         LDKChannelConfig this_ptr_conv;
24682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24683         this_ptr_conv.is_owned = false;
24684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24685         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
24686         return ret_conv;
24687 }
24688
24689 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) {
24690         LDKChannelConfig this_ptr_conv;
24691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24692         this_ptr_conv.is_owned = false;
24693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24694         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
24695 }
24696
24697 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) {
24698         LDKChannelConfig this_ptr_conv;
24699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24700         this_ptr_conv.is_owned = false;
24701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24702         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
24703         return ret_conv;
24704 }
24705
24706 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) {
24707         LDKChannelConfig this_ptr_conv;
24708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24709         this_ptr_conv.is_owned = false;
24710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24711         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
24712 }
24713
24714 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) {
24715         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);
24716         int64_t ret_ref = 0;
24717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24720         ret_ref = (uintptr_t)ret_var.inner;
24721         if (ret_var.is_owned) {
24722                 ret_ref |= 1;
24723         }
24724         return ret_ref;
24725 }
24726
24727 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
24728         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
24729 int64_t ret_ref = 0;
24730 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24731 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24732 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24733 ret_ref = (uintptr_t)ret_var.inner;
24734 if (ret_var.is_owned) {
24735         ret_ref |= 1;
24736 }
24737         return ret_ref;
24738 }
24739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24740         LDKChannelConfig arg_conv;
24741         arg_conv.inner = (void*)(arg & (~1));
24742         arg_conv.is_owned = false;
24743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24744         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
24745         return ret_conv;
24746 }
24747
24748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24749         LDKChannelConfig orig_conv;
24750         orig_conv.inner = (void*)(orig & (~1));
24751         orig_conv.is_owned = false;
24752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24753         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
24754         int64_t ret_ref = 0;
24755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24758         ret_ref = (uintptr_t)ret_var.inner;
24759         if (ret_var.is_owned) {
24760                 ret_ref |= 1;
24761         }
24762         return ret_ref;
24763 }
24764
24765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
24766         LDKChannelConfig ret_var = ChannelConfig_default();
24767         int64_t ret_ref = 0;
24768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24771         ret_ref = (uintptr_t)ret_var.inner;
24772         if (ret_var.is_owned) {
24773                 ret_ref |= 1;
24774         }
24775         return ret_ref;
24776 }
24777
24778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
24779         LDKChannelConfig obj_conv;
24780         obj_conv.inner = (void*)(obj & (~1));
24781         obj_conv.is_owned = false;
24782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24783         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
24784         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24785         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24786         CVec_u8Z_free(ret_var);
24787         return ret_arr;
24788 }
24789
24790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24791         LDKu8slice ser_ref;
24792         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24793         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24794         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
24795         *ret_conv = ChannelConfig_read(ser_ref);
24796         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24797         return (int64_t)ret_conv;
24798 }
24799
24800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24801         LDKUserConfig this_obj_conv;
24802         this_obj_conv.inner = (void*)(this_obj & (~1));
24803         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24805         UserConfig_free(this_obj_conv);
24806 }
24807
24808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
24809         LDKUserConfig this_ptr_conv;
24810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24811         this_ptr_conv.is_owned = false;
24812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24813         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
24814         int64_t ret_ref = 0;
24815         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24816         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24818         ret_ref = (uintptr_t)ret_var.inner;
24819         if (ret_var.is_owned) {
24820                 ret_ref |= 1;
24821         }
24822         return ret_ref;
24823 }
24824
24825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24826         LDKUserConfig this_ptr_conv;
24827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24828         this_ptr_conv.is_owned = false;
24829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24830         LDKChannelHandshakeConfig val_conv;
24831         val_conv.inner = (void*)(val & (~1));
24832         val_conv.is_owned = (val & 1) || (val == 0);
24833         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24834         val_conv = ChannelHandshakeConfig_clone(&val_conv);
24835         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
24836 }
24837
24838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
24839         LDKUserConfig this_ptr_conv;
24840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24841         this_ptr_conv.is_owned = false;
24842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24843         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
24844         int64_t ret_ref = 0;
24845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24848         ret_ref = (uintptr_t)ret_var.inner;
24849         if (ret_var.is_owned) {
24850                 ret_ref |= 1;
24851         }
24852         return ret_ref;
24853 }
24854
24855 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) {
24856         LDKUserConfig this_ptr_conv;
24857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24858         this_ptr_conv.is_owned = false;
24859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24860         LDKChannelHandshakeLimits val_conv;
24861         val_conv.inner = (void*)(val & (~1));
24862         val_conv.is_owned = (val & 1) || (val == 0);
24863         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24864         val_conv = ChannelHandshakeLimits_clone(&val_conv);
24865         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
24866 }
24867
24868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
24869         LDKUserConfig this_ptr_conv;
24870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24871         this_ptr_conv.is_owned = false;
24872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24873         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
24874         int64_t ret_ref = 0;
24875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24878         ret_ref = (uintptr_t)ret_var.inner;
24879         if (ret_var.is_owned) {
24880                 ret_ref |= 1;
24881         }
24882         return ret_ref;
24883 }
24884
24885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24886         LDKUserConfig this_ptr_conv;
24887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24888         this_ptr_conv.is_owned = false;
24889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24890         LDKChannelConfig val_conv;
24891         val_conv.inner = (void*)(val & (~1));
24892         val_conv.is_owned = (val & 1) || (val == 0);
24893         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24894         val_conv = ChannelConfig_clone(&val_conv);
24895         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
24896 }
24897
24898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24899         LDKUserConfig this_ptr_conv;
24900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24901         this_ptr_conv.is_owned = false;
24902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24903         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
24904         return ret_conv;
24905 }
24906
24907 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) {
24908         LDKUserConfig this_ptr_conv;
24909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24910         this_ptr_conv.is_owned = false;
24911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24912         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
24913 }
24914
24915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24916         LDKUserConfig this_ptr_conv;
24917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24918         this_ptr_conv.is_owned = false;
24919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24920         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
24921         return ret_conv;
24922 }
24923
24924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24925         LDKUserConfig this_ptr_conv;
24926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24927         this_ptr_conv.is_owned = false;
24928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24929         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
24930 }
24931
24932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24933         LDKUserConfig 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         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
24938         return ret_conv;
24939 }
24940
24941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24942         LDKUserConfig this_ptr_conv;
24943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24944         this_ptr_conv.is_owned = false;
24945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24946         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
24947 }
24948
24949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
24950         LDKChannelHandshakeConfig own_channel_config_arg_conv;
24951         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
24952         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
24953         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
24954         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
24955         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
24956         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
24957         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
24959         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
24960         LDKChannelConfig channel_options_arg_conv;
24961         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
24962         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
24963         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
24964         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
24965         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
24966         int64_t ret_ref = 0;
24967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24970         ret_ref = (uintptr_t)ret_var.inner;
24971         if (ret_var.is_owned) {
24972                 ret_ref |= 1;
24973         }
24974         return ret_ref;
24975 }
24976
24977 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
24978         LDKUserConfig ret_var = UserConfig_clone(arg);
24979 int64_t ret_ref = 0;
24980 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24981 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24982 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24983 ret_ref = (uintptr_t)ret_var.inner;
24984 if (ret_var.is_owned) {
24985         ret_ref |= 1;
24986 }
24987         return ret_ref;
24988 }
24989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24990         LDKUserConfig arg_conv;
24991         arg_conv.inner = (void*)(arg & (~1));
24992         arg_conv.is_owned = false;
24993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24994         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
24995         return ret_conv;
24996 }
24997
24998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24999         LDKUserConfig orig_conv;
25000         orig_conv.inner = (void*)(orig & (~1));
25001         orig_conv.is_owned = false;
25002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25003         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
25004         int64_t ret_ref = 0;
25005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25008         ret_ref = (uintptr_t)ret_var.inner;
25009         if (ret_var.is_owned) {
25010                 ret_ref |= 1;
25011         }
25012         return ret_ref;
25013 }
25014
25015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
25016         LDKUserConfig ret_var = UserConfig_default();
25017         int64_t ret_ref = 0;
25018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25021         ret_ref = (uintptr_t)ret_var.inner;
25022         if (ret_var.is_owned) {
25023                 ret_ref |= 1;
25024         }
25025         return ret_ref;
25026 }
25027
25028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25029         LDKBestBlock this_obj_conv;
25030         this_obj_conv.inner = (void*)(this_obj & (~1));
25031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25033         BestBlock_free(this_obj_conv);
25034 }
25035
25036 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
25037         LDKBestBlock ret_var = BestBlock_clone(arg);
25038 int64_t ret_ref = 0;
25039 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25040 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25041 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25042 ret_ref = (uintptr_t)ret_var.inner;
25043 if (ret_var.is_owned) {
25044         ret_ref |= 1;
25045 }
25046         return ret_ref;
25047 }
25048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25049         LDKBestBlock arg_conv;
25050         arg_conv.inner = (void*)(arg & (~1));
25051         arg_conv.is_owned = false;
25052         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25053         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
25054         return ret_conv;
25055 }
25056
25057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25058         LDKBestBlock orig_conv;
25059         orig_conv.inner = (void*)(orig & (~1));
25060         orig_conv.is_owned = false;
25061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25062         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25063         int64_t ret_ref = 0;
25064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25067         ret_ref = (uintptr_t)ret_var.inner;
25068         if (ret_var.is_owned) {
25069                 ret_ref |= 1;
25070         }
25071         return ret_ref;
25072 }
25073
25074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25075         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25076         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
25077         int64_t ret_ref = 0;
25078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25081         ret_ref = (uintptr_t)ret_var.inner;
25082         if (ret_var.is_owned) {
25083                 ret_ref |= 1;
25084         }
25085         return ret_ref;
25086 }
25087
25088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25089         LDKThirtyTwoBytes block_hash_ref;
25090         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25091         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25092         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25093         int64_t ret_ref = 0;
25094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25097         ret_ref = (uintptr_t)ret_var.inner;
25098         if (ret_var.is_owned) {
25099                 ret_ref |= 1;
25100         }
25101         return ret_ref;
25102 }
25103
25104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25105         LDKBestBlock this_arg_conv;
25106         this_arg_conv.inner = (void*)(this_arg & (~1));
25107         this_arg_conv.is_owned = false;
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25109         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25111         return ret_arr;
25112 }
25113
25114 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25115         LDKBestBlock this_arg_conv;
25116         this_arg_conv.inner = (void*)(this_arg & (~1));
25117         this_arg_conv.is_owned = false;
25118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25119         int32_t ret_conv = BestBlock_height(&this_arg_conv);
25120         return ret_conv;
25121 }
25122
25123 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25124         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
25125         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25126         return ret_conv;
25127 }
25128
25129 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
25130         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
25131         return ret_conv;
25132 }
25133
25134 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
25135         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
25136         return ret_conv;
25137 }
25138
25139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25140         if ((this_ptr & 1) != 0) return;
25141         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25142         CHECK_ACCESS(this_ptr_ptr);
25143         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
25144         FREE((void*)this_ptr);
25145         Access_free(this_ptr_conv);
25146 }
25147
25148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25149         if ((this_ptr & 1) != 0) return;
25150         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25151         CHECK_ACCESS(this_ptr_ptr);
25152         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
25153         FREE((void*)this_ptr);
25154         Listen_free(this_ptr_conv);
25155 }
25156
25157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25158         if ((this_ptr & 1) != 0) return;
25159         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25160         CHECK_ACCESS(this_ptr_ptr);
25161         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
25162         FREE((void*)this_ptr);
25163         Confirm_free(this_ptr_conv);
25164 }
25165
25166 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25167         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
25168         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
25169         return ret_conv;
25170 }
25171
25172 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
25173         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
25174         return ret_conv;
25175 }
25176
25177 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
25178         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
25179         return ret_conv;
25180 }
25181
25182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25183         if ((this_ptr & 1) != 0) return;
25184         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25185         CHECK_ACCESS(this_ptr_ptr);
25186         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
25187         FREE((void*)this_ptr);
25188         Watch_free(this_ptr_conv);
25189 }
25190
25191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25192         if ((this_ptr & 1) != 0) return;
25193         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25194         CHECK_ACCESS(this_ptr_ptr);
25195         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
25196         FREE((void*)this_ptr);
25197         Filter_free(this_ptr_conv);
25198 }
25199
25200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25201         LDKWatchedOutput this_obj_conv;
25202         this_obj_conv.inner = (void*)(this_obj & (~1));
25203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25205         WatchedOutput_free(this_obj_conv);
25206 }
25207
25208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25209         LDKWatchedOutput this_ptr_conv;
25210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25211         this_ptr_conv.is_owned = false;
25212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25213         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
25215         return ret_arr;
25216 }
25217
25218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25219         LDKWatchedOutput this_ptr_conv;
25220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25221         this_ptr_conv.is_owned = false;
25222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25223         LDKThirtyTwoBytes val_ref;
25224         CHECK((*env)->GetArrayLength(env, val) == 32);
25225         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25226         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
25227 }
25228
25229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25230         LDKWatchedOutput this_ptr_conv;
25231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25232         this_ptr_conv.is_owned = false;
25233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25234         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
25235         int64_t ret_ref = 0;
25236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25239         ret_ref = (uintptr_t)ret_var.inner;
25240         if (ret_var.is_owned) {
25241                 ret_ref |= 1;
25242         }
25243         return ret_ref;
25244 }
25245
25246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25247         LDKWatchedOutput this_ptr_conv;
25248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25249         this_ptr_conv.is_owned = false;
25250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25251         LDKOutPoint val_conv;
25252         val_conv.inner = (void*)(val & (~1));
25253         val_conv.is_owned = (val & 1) || (val == 0);
25254         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25255         val_conv = OutPoint_clone(&val_conv);
25256         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
25257 }
25258
25259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25260         LDKWatchedOutput this_ptr_conv;
25261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25262         this_ptr_conv.is_owned = false;
25263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25264         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
25265         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25266         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25267         return ret_arr;
25268 }
25269
25270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25271         LDKWatchedOutput this_ptr_conv;
25272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25273         this_ptr_conv.is_owned = false;
25274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25275         LDKCVec_u8Z val_ref;
25276         val_ref.datalen = (*env)->GetArrayLength(env, val);
25277         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
25278         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
25279         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
25280 }
25281
25282 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) {
25283         LDKThirtyTwoBytes block_hash_arg_ref;
25284         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
25285         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
25286         LDKOutPoint outpoint_arg_conv;
25287         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
25288         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
25289         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25290         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25291         LDKCVec_u8Z script_pubkey_arg_ref;
25292         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
25293         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
25294         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
25295         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
25296         int64_t ret_ref = 0;
25297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25300         ret_ref = (uintptr_t)ret_var.inner;
25301         if (ret_var.is_owned) {
25302                 ret_ref |= 1;
25303         }
25304         return ret_ref;
25305 }
25306
25307 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
25308         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
25309 int64_t ret_ref = 0;
25310 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25311 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25312 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25313 ret_ref = (uintptr_t)ret_var.inner;
25314 if (ret_var.is_owned) {
25315         ret_ref |= 1;
25316 }
25317         return ret_ref;
25318 }
25319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25320         LDKWatchedOutput arg_conv;
25321         arg_conv.inner = (void*)(arg & (~1));
25322         arg_conv.is_owned = false;
25323         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25324         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
25325         return ret_conv;
25326 }
25327
25328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25329         LDKWatchedOutput orig_conv;
25330         orig_conv.inner = (void*)(orig & (~1));
25331         orig_conv.is_owned = false;
25332         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25333         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
25334         int64_t ret_ref = 0;
25335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25338         ret_ref = (uintptr_t)ret_var.inner;
25339         if (ret_var.is_owned) {
25340                 ret_ref |= 1;
25341         }
25342         return ret_ref;
25343 }
25344
25345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
25346         LDKWatchedOutput o_conv;
25347         o_conv.inner = (void*)(o & (~1));
25348         o_conv.is_owned = false;
25349         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25350         int64_t ret_conv = WatchedOutput_hash(&o_conv);
25351         return ret_conv;
25352 }
25353
25354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25355         if ((this_ptr & 1) != 0) return;
25356         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25357         CHECK_ACCESS(this_ptr_ptr);
25358         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
25359         FREE((void*)this_ptr);
25360         BroadcasterInterface_free(this_ptr_conv);
25361 }
25362
25363 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25364         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
25365         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
25366         return ret_conv;
25367 }
25368
25369 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
25370         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
25371         return ret_conv;
25372 }
25373
25374 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
25375         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
25376         return ret_conv;
25377 }
25378
25379 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
25380         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
25381         return ret_conv;
25382 }
25383
25384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25385         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
25386         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
25387         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
25388         return ret_conv;
25389 }
25390
25391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25392         if ((this_ptr & 1) != 0) return;
25393         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25394         CHECK_ACCESS(this_ptr_ptr);
25395         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
25396         FREE((void*)this_ptr);
25397         FeeEstimator_free(this_ptr_conv);
25398 }
25399
25400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25401         LDKMonitorUpdateId this_obj_conv;
25402         this_obj_conv.inner = (void*)(this_obj & (~1));
25403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25405         MonitorUpdateId_free(this_obj_conv);
25406 }
25407
25408 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
25409         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
25410 int64_t ret_ref = 0;
25411 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25412 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25413 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25414 ret_ref = (uintptr_t)ret_var.inner;
25415 if (ret_var.is_owned) {
25416         ret_ref |= 1;
25417 }
25418         return ret_ref;
25419 }
25420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25421         LDKMonitorUpdateId arg_conv;
25422         arg_conv.inner = (void*)(arg & (~1));
25423         arg_conv.is_owned = false;
25424         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25425         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
25426         return ret_conv;
25427 }
25428
25429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25430         LDKMonitorUpdateId orig_conv;
25431         orig_conv.inner = (void*)(orig & (~1));
25432         orig_conv.is_owned = false;
25433         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25434         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
25435         int64_t ret_ref = 0;
25436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25439         ret_ref = (uintptr_t)ret_var.inner;
25440         if (ret_var.is_owned) {
25441                 ret_ref |= 1;
25442         }
25443         return ret_ref;
25444 }
25445
25446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
25447         LDKMonitorUpdateId o_conv;
25448         o_conv.inner = (void*)(o & (~1));
25449         o_conv.is_owned = false;
25450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25451         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
25452         return ret_conv;
25453 }
25454
25455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25456         LDKMonitorUpdateId a_conv;
25457         a_conv.inner = (void*)(a & (~1));
25458         a_conv.is_owned = false;
25459         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25460         LDKMonitorUpdateId b_conv;
25461         b_conv.inner = (void*)(b & (~1));
25462         b_conv.is_owned = false;
25463         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
25464         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
25465         return ret_conv;
25466 }
25467
25468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25469         if ((this_ptr & 1) != 0) return;
25470         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25471         CHECK_ACCESS(this_ptr_ptr);
25472         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
25473         FREE((void*)this_ptr);
25474         Persist_free(this_ptr_conv);
25475 }
25476
25477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25478         LDKLockedChannelMonitor this_obj_conv;
25479         this_obj_conv.inner = (void*)(this_obj & (~1));
25480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25482         LockedChannelMonitor_free(this_obj_conv);
25483 }
25484
25485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25486         LDKChainMonitor this_obj_conv;
25487         this_obj_conv.inner = (void*)(this_obj & (~1));
25488         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25490         ChainMonitor_free(this_obj_conv);
25491 }
25492
25493 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) {
25494         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
25495         CHECK_ACCESS(chain_source_ptr);
25496         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
25497         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
25498         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
25499                 // Manually implement clone for Java trait instances
25500                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
25501                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25502                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
25503                 }
25504         }
25505         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25506         CHECK_ACCESS(broadcaster_ptr);
25507         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25508         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25509                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25510                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25511         }
25512         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25513         CHECK_ACCESS(logger_ptr);
25514         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25515         if (logger_conv.free == LDKLogger_JCalls_free) {
25516                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25517                 LDKLogger_JCalls_cloned(&logger_conv);
25518         }
25519         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
25520         CHECK_ACCESS(feeest_ptr);
25521         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
25522         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
25523                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25524                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
25525         }
25526         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
25527         CHECK_ACCESS(persister_ptr);
25528         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
25529         if (persister_conv.free == LDKPersist_JCalls_free) {
25530                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25531                 LDKPersist_JCalls_cloned(&persister_conv);
25532         }
25533         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
25534         int64_t ret_ref = 0;
25535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25538         ret_ref = (uintptr_t)ret_var.inner;
25539         if (ret_var.is_owned) {
25540                 ret_ref |= 1;
25541         }
25542         return ret_ref;
25543 }
25544
25545 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) {
25546         LDKChainMonitor this_arg_conv;
25547         this_arg_conv.inner = (void*)(this_arg & (~1));
25548         this_arg_conv.is_owned = false;
25549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25550         LDKCVec_ChannelDetailsZ ignored_channels_constr;
25551         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
25552         if (ignored_channels_constr.datalen > 0)
25553                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25554         else
25555                 ignored_channels_constr.data = NULL;
25556         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
25557         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
25558                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
25559                 LDKChannelDetails ignored_channels_conv_16_conv;
25560                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
25561                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
25562                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
25563                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
25564                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
25565         }
25566         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
25567         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
25568         int64_tArray ret_arr = NULL;
25569         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25570         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25571         for (size_t j = 0; j < ret_var.datalen; j++) {
25572                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25573                 *ret_conv_9_copy = ret_var.data[j];
25574                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
25575                 ret_arr_ptr[j] = ret_conv_9_ref;
25576         }
25577         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25578         FREE(ret_var.data);
25579         return ret_arr;
25580 }
25581
25582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
25583         LDKChainMonitor this_arg_conv;
25584         this_arg_conv.inner = (void*)(this_arg & (~1));
25585         this_arg_conv.is_owned = false;
25586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25587         LDKOutPoint funding_txo_conv;
25588         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25589         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25591         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25592         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25593         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
25594         return (int64_t)ret_conv;
25595 }
25596
25597 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
25598         LDKChainMonitor this_arg_conv;
25599         this_arg_conv.inner = (void*)(this_arg & (~1));
25600         this_arg_conv.is_owned = false;
25601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25602         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
25603         int64_tArray ret_arr = NULL;
25604         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25605         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25606         for (size_t k = 0; k < ret_var.datalen; k++) {
25607                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
25608                 int64_t ret_conv_10_ref = 0;
25609                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25610                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25611                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
25612                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
25613                 if (ret_conv_10_var.is_owned) {
25614                         ret_conv_10_ref |= 1;
25615                 }
25616                 ret_arr_ptr[k] = ret_conv_10_ref;
25617         }
25618         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25619         FREE(ret_var.data);
25620         return ret_arr;
25621 }
25622
25623 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) {
25624         LDKChainMonitor this_arg_conv;
25625         this_arg_conv.inner = (void*)(this_arg & (~1));
25626         this_arg_conv.is_owned = false;
25627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25628         LDKOutPoint funding_txo_conv;
25629         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25630         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25631         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25632         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25633         LDKMonitorUpdateId completed_update_id_conv;
25634         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
25635         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
25636         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
25637         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
25638         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25639         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
25640         return (int64_t)ret_conv;
25641 }
25642
25643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25644         LDKChainMonitor this_arg_conv;
25645         this_arg_conv.inner = (void*)(this_arg & (~1));
25646         this_arg_conv.is_owned = false;
25647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25648         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25649         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
25650         return (int64_t)ret_ret;
25651 }
25652
25653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25654         LDKChainMonitor this_arg_conv;
25655         this_arg_conv.inner = (void*)(this_arg & (~1));
25656         this_arg_conv.is_owned = false;
25657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25658         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25659         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
25660         return (int64_t)ret_ret;
25661 }
25662
25663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25664         LDKChainMonitor this_arg_conv;
25665         this_arg_conv.inner = (void*)(this_arg & (~1));
25666         this_arg_conv.is_owned = false;
25667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25668         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
25669         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
25670         return (int64_t)ret_ret;
25671 }
25672
25673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25674         LDKChainMonitor 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         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25679         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
25680         return (int64_t)ret_ret;
25681 }
25682
25683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25684         LDKChannelMonitorUpdate this_obj_conv;
25685         this_obj_conv.inner = (void*)(this_obj & (~1));
25686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25688         ChannelMonitorUpdate_free(this_obj_conv);
25689 }
25690
25691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25692         LDKChannelMonitorUpdate this_ptr_conv;
25693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25694         this_ptr_conv.is_owned = false;
25695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25696         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
25697         return ret_conv;
25698 }
25699
25700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25701         LDKChannelMonitorUpdate this_ptr_conv;
25702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25703         this_ptr_conv.is_owned = false;
25704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25705         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
25706 }
25707
25708 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
25709         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
25710 int64_t ret_ref = 0;
25711 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25712 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25713 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25714 ret_ref = (uintptr_t)ret_var.inner;
25715 if (ret_var.is_owned) {
25716         ret_ref |= 1;
25717 }
25718         return ret_ref;
25719 }
25720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25721         LDKChannelMonitorUpdate arg_conv;
25722         arg_conv.inner = (void*)(arg & (~1));
25723         arg_conv.is_owned = false;
25724         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25725         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
25726         return ret_conv;
25727 }
25728
25729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25730         LDKChannelMonitorUpdate orig_conv;
25731         orig_conv.inner = (void*)(orig & (~1));
25732         orig_conv.is_owned = false;
25733         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25734         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
25735         int64_t ret_ref = 0;
25736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25739         ret_ref = (uintptr_t)ret_var.inner;
25740         if (ret_var.is_owned) {
25741                 ret_ref |= 1;
25742         }
25743         return ret_ref;
25744 }
25745
25746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25747         LDKChannelMonitorUpdate obj_conv;
25748         obj_conv.inner = (void*)(obj & (~1));
25749         obj_conv.is_owned = false;
25750         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25751         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
25752         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25753         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25754         CVec_u8Z_free(ret_var);
25755         return ret_arr;
25756 }
25757
25758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25759         LDKu8slice ser_ref;
25760         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25761         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25762         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
25763         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
25764         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25765         return (int64_t)ret_conv;
25766 }
25767
25768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25769         if ((this_ptr & 1) != 0) return;
25770         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25771         CHECK_ACCESS(this_ptr_ptr);
25772         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
25773         FREE((void*)this_ptr);
25774         MonitorEvent_free(this_ptr_conv);
25775 }
25776
25777 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
25778         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25779         *ret_copy = MonitorEvent_clone(arg);
25780 int64_t ret_ref = (uintptr_t)ret_copy;
25781         return ret_ref;
25782 }
25783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25784         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
25785         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
25786         return ret_conv;
25787 }
25788
25789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25790         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
25791         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25792         *ret_copy = MonitorEvent_clone(orig_conv);
25793         int64_t ret_ref = (uintptr_t)ret_copy;
25794         return ret_ref;
25795 }
25796
25797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
25798         LDKHTLCUpdate a_conv;
25799         a_conv.inner = (void*)(a & (~1));
25800         a_conv.is_owned = (a & 1) || (a == 0);
25801         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25802         a_conv = HTLCUpdate_clone(&a_conv);
25803         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25804         *ret_copy = MonitorEvent_htlcevent(a_conv);
25805         int64_t ret_ref = (uintptr_t)ret_copy;
25806         return ret_ref;
25807 }
25808
25809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
25810         LDKOutPoint a_conv;
25811         a_conv.inner = (void*)(a & (~1));
25812         a_conv.is_owned = (a & 1) || (a == 0);
25813         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25814         a_conv = OutPoint_clone(&a_conv);
25815         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25816         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
25817         int64_t ret_ref = (uintptr_t)ret_copy;
25818         return ret_ref;
25819 }
25820
25821 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) {
25822         LDKOutPoint funding_txo_conv;
25823         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25824         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25826         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25827         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25828         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
25829         int64_t ret_ref = (uintptr_t)ret_copy;
25830         return ret_ref;
25831 }
25832
25833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
25834         LDKOutPoint a_conv;
25835         a_conv.inner = (void*)(a & (~1));
25836         a_conv.is_owned = (a & 1) || (a == 0);
25837         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25838         a_conv = OutPoint_clone(&a_conv);
25839         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25840         *ret_copy = MonitorEvent_update_failed(a_conv);
25841         int64_t ret_ref = (uintptr_t)ret_copy;
25842         return ret_ref;
25843 }
25844
25845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
25846         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
25847         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
25848         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25849         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25850         CVec_u8Z_free(ret_var);
25851         return ret_arr;
25852 }
25853
25854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25855         LDKu8slice ser_ref;
25856         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25857         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25858         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
25859         *ret_conv = MonitorEvent_read(ser_ref);
25860         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25861         return (int64_t)ret_conv;
25862 }
25863
25864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25865         LDKHTLCUpdate this_obj_conv;
25866         this_obj_conv.inner = (void*)(this_obj & (~1));
25867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25869         HTLCUpdate_free(this_obj_conv);
25870 }
25871
25872 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
25873         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
25874 int64_t ret_ref = 0;
25875 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25876 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25877 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25878 ret_ref = (uintptr_t)ret_var.inner;
25879 if (ret_var.is_owned) {
25880         ret_ref |= 1;
25881 }
25882         return ret_ref;
25883 }
25884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25885         LDKHTLCUpdate arg_conv;
25886         arg_conv.inner = (void*)(arg & (~1));
25887         arg_conv.is_owned = false;
25888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25889         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
25890         return ret_conv;
25891 }
25892
25893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25894         LDKHTLCUpdate orig_conv;
25895         orig_conv.inner = (void*)(orig & (~1));
25896         orig_conv.is_owned = false;
25897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25898         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
25899         int64_t ret_ref = 0;
25900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25903         ret_ref = (uintptr_t)ret_var.inner;
25904         if (ret_var.is_owned) {
25905                 ret_ref |= 1;
25906         }
25907         return ret_ref;
25908 }
25909
25910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25911         LDKHTLCUpdate obj_conv;
25912         obj_conv.inner = (void*)(obj & (~1));
25913         obj_conv.is_owned = false;
25914         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25915         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
25916         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25917         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25918         CVec_u8Z_free(ret_var);
25919         return ret_arr;
25920 }
25921
25922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25923         LDKu8slice ser_ref;
25924         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25925         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25926         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
25927         *ret_conv = HTLCUpdate_read(ser_ref);
25928         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25929         return (int64_t)ret_conv;
25930 }
25931
25932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25933         if ((this_ptr & 1) != 0) return;
25934         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25935         CHECK_ACCESS(this_ptr_ptr);
25936         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
25937         FREE((void*)this_ptr);
25938         Balance_free(this_ptr_conv);
25939 }
25940
25941 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
25942         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25943         *ret_copy = Balance_clone(arg);
25944 int64_t ret_ref = (uintptr_t)ret_copy;
25945         return ret_ref;
25946 }
25947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25948         LDKBalance* arg_conv = (LDKBalance*)arg;
25949         int64_t ret_conv = Balance_clone_ptr(arg_conv);
25950         return ret_conv;
25951 }
25952
25953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25954         LDKBalance* orig_conv = (LDKBalance*)orig;
25955         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25956         *ret_copy = Balance_clone(orig_conv);
25957         int64_t ret_ref = (uintptr_t)ret_copy;
25958         return ret_ref;
25959 }
25960
25961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
25962         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25963         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
25964         int64_t ret_ref = (uintptr_t)ret_copy;
25965         return ret_ref;
25966 }
25967
25968 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) {
25969         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25970         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
25971         int64_t ret_ref = (uintptr_t)ret_copy;
25972         return ret_ref;
25973 }
25974
25975 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) {
25976         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25977         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
25978         int64_t ret_ref = (uintptr_t)ret_copy;
25979         return ret_ref;
25980 }
25981
25982 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) {
25983         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25984         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
25985         int64_t ret_ref = (uintptr_t)ret_copy;
25986         return ret_ref;
25987 }
25988
25989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25990         LDKBalance* a_conv = (LDKBalance*)a;
25991         LDKBalance* b_conv = (LDKBalance*)b;
25992         jboolean ret_conv = Balance_eq(a_conv, b_conv);
25993         return ret_conv;
25994 }
25995
25996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25997         LDKChannelMonitor this_obj_conv;
25998         this_obj_conv.inner = (void*)(this_obj & (~1));
25999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26001         ChannelMonitor_free(this_obj_conv);
26002 }
26003
26004 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
26005         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
26006 int64_t ret_ref = 0;
26007 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26008 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26009 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26010 ret_ref = (uintptr_t)ret_var.inner;
26011 if (ret_var.is_owned) {
26012         ret_ref |= 1;
26013 }
26014         return ret_ref;
26015 }
26016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26017         LDKChannelMonitor arg_conv;
26018         arg_conv.inner = (void*)(arg & (~1));
26019         arg_conv.is_owned = false;
26020         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26021         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
26022         return ret_conv;
26023 }
26024
26025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26026         LDKChannelMonitor orig_conv;
26027         orig_conv.inner = (void*)(orig & (~1));
26028         orig_conv.is_owned = false;
26029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26030         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
26031         int64_t ret_ref = 0;
26032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26035         ret_ref = (uintptr_t)ret_var.inner;
26036         if (ret_var.is_owned) {
26037                 ret_ref |= 1;
26038         }
26039         return ret_ref;
26040 }
26041
26042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26043         LDKChannelMonitor obj_conv;
26044         obj_conv.inner = (void*)(obj & (~1));
26045         obj_conv.is_owned = false;
26046         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26047         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
26048         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26049         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26050         CVec_u8Z_free(ret_var);
26051         return ret_arr;
26052 }
26053
26054 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) {
26055         LDKChannelMonitor this_arg_conv;
26056         this_arg_conv.inner = (void*)(this_arg & (~1));
26057         this_arg_conv.is_owned = false;
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26059         LDKChannelMonitorUpdate updates_conv;
26060         updates_conv.inner = (void*)(updates & (~1));
26061         updates_conv.is_owned = false;
26062         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26063         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26064         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
26065         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26066         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26067         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
26068         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
26069         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26070         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26071         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26072         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26073         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26074         return (int64_t)ret_conv;
26075 }
26076
26077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26078         LDKChannelMonitor this_arg_conv;
26079         this_arg_conv.inner = (void*)(this_arg & (~1));
26080         this_arg_conv.is_owned = false;
26081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26082         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26083         return ret_conv;
26084 }
26085
26086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26087         LDKChannelMonitor this_arg_conv;
26088         this_arg_conv.inner = (void*)(this_arg & (~1));
26089         this_arg_conv.is_owned = false;
26090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26091         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26092         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26093         return ((int64_t)ret_conv);
26094 }
26095
26096 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26097         LDKChannelMonitor this_arg_conv;
26098         this_arg_conv.inner = (void*)(this_arg & (~1));
26099         this_arg_conv.is_owned = false;
26100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26101         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26102         int64_tArray ret_arr = NULL;
26103         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26104         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26105         for (size_t o = 0; o < ret_var.datalen; o++) {
26106                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26107                 *ret_conv_40_conv = ret_var.data[o];
26108                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
26109         }
26110         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26111         FREE(ret_var.data);
26112         return ret_arr;
26113 }
26114
26115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26116         LDKChannelMonitor this_arg_conv;
26117         this_arg_conv.inner = (void*)(this_arg & (~1));
26118         this_arg_conv.is_owned = false;
26119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26120         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
26121         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
26122         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26123         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26124 }
26125
26126 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26127         LDKChannelMonitor this_arg_conv;
26128         this_arg_conv.inner = (void*)(this_arg & (~1));
26129         this_arg_conv.is_owned = false;
26130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26131         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
26132         int64_tArray ret_arr = NULL;
26133         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26134         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26135         for (size_t o = 0; o < ret_var.datalen; o++) {
26136                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26137                 *ret_conv_14_copy = ret_var.data[o];
26138                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
26139                 ret_arr_ptr[o] = ret_conv_14_ref;
26140         }
26141         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26142         FREE(ret_var.data);
26143         return ret_arr;
26144 }
26145
26146 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26147         LDKChannelMonitor this_arg_conv;
26148         this_arg_conv.inner = (void*)(this_arg & (~1));
26149         this_arg_conv.is_owned = false;
26150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26151         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
26152         int64_tArray ret_arr = NULL;
26153         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26154         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26155         for (size_t h = 0; h < ret_var.datalen; h++) {
26156                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26157                 *ret_conv_7_copy = ret_var.data[h];
26158                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
26159                 ret_arr_ptr[h] = ret_conv_7_ref;
26160         }
26161         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26162         FREE(ret_var.data);
26163         return ret_arr;
26164 }
26165
26166 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) {
26167         LDKChannelMonitor this_arg_conv;
26168         this_arg_conv.inner = (void*)(this_arg & (~1));
26169         this_arg_conv.is_owned = false;
26170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26171         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26172         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26173         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26174         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
26175         jobjectArray ret_arr = NULL;
26176         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26177         ;
26178         for (size_t i = 0; i < ret_var.datalen; i++) {
26179                 LDKTransaction ret_conv_8_var = ret_var.data[i];
26180                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
26181                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
26182                 Transaction_free(ret_conv_8_var);
26183                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26184         }
26185         
26186         FREE(ret_var.data);
26187         return ret_arr;
26188 }
26189
26190 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) {
26191         LDKChannelMonitor this_arg_conv;
26192         this_arg_conv.inner = (void*)(this_arg & (~1));
26193         this_arg_conv.is_owned = false;
26194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26195         unsigned char header_arr[80];
26196         CHECK((*env)->GetArrayLength(env, header) == 80);
26197         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26198         unsigned char (*header_ref)[80] = &header_arr;
26199         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26200         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26201         if (txdata_constr.datalen > 0)
26202                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26203         else
26204                 txdata_constr.data = NULL;
26205         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26206         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26207                 int64_t txdata_conv_28 = txdata_vals[c];
26208                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26209                 CHECK_ACCESS(txdata_conv_28_ptr);
26210                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26211                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26212                 txdata_constr.data[c] = txdata_conv_28_conv;
26213         }
26214         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26215         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26216         CHECK_ACCESS(broadcaster_ptr);
26217         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26218         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26219                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26220                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26221         }
26222         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26223         CHECK_ACCESS(fee_estimator_ptr);
26224         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26225         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26226                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26227                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26228         }
26229         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26230         CHECK_ACCESS(logger_ptr);
26231         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26232         if (logger_conv.free == LDKLogger_JCalls_free) {
26233                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26234                 LDKLogger_JCalls_cloned(&logger_conv);
26235         }
26236         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);
26237         int64_tArray ret_arr = NULL;
26238         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26239         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26240         for (size_t n = 0; n < ret_var.datalen; n++) {
26241                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26242                 *ret_conv_39_conv = ret_var.data[n];
26243                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26244         }
26245         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26246         FREE(ret_var.data);
26247         return ret_arr;
26248 }
26249
26250 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) {
26251         LDKChannelMonitor this_arg_conv;
26252         this_arg_conv.inner = (void*)(this_arg & (~1));
26253         this_arg_conv.is_owned = false;
26254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26255         unsigned char header_arr[80];
26256         CHECK((*env)->GetArrayLength(env, header) == 80);
26257         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26258         unsigned char (*header_ref)[80] = &header_arr;
26259         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26260         CHECK_ACCESS(broadcaster_ptr);
26261         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26262         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26263                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26264                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26265         }
26266         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26267         CHECK_ACCESS(fee_estimator_ptr);
26268         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26269         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26270                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26271                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26272         }
26273         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26274         CHECK_ACCESS(logger_ptr);
26275         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26276         if (logger_conv.free == LDKLogger_JCalls_free) {
26277                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26278                 LDKLogger_JCalls_cloned(&logger_conv);
26279         }
26280         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26281 }
26282
26283 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) {
26284         LDKChannelMonitor this_arg_conv;
26285         this_arg_conv.inner = (void*)(this_arg & (~1));
26286         this_arg_conv.is_owned = false;
26287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26288         unsigned char header_arr[80];
26289         CHECK((*env)->GetArrayLength(env, header) == 80);
26290         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26291         unsigned char (*header_ref)[80] = &header_arr;
26292         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26293         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26294         if (txdata_constr.datalen > 0)
26295                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26296         else
26297                 txdata_constr.data = NULL;
26298         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26299         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26300                 int64_t txdata_conv_28 = txdata_vals[c];
26301                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26302                 CHECK_ACCESS(txdata_conv_28_ptr);
26303                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26304                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26305                 txdata_constr.data[c] = txdata_conv_28_conv;
26306         }
26307         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26308         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26309         CHECK_ACCESS(broadcaster_ptr);
26310         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26311         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26312                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26313                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26314         }
26315         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26316         CHECK_ACCESS(fee_estimator_ptr);
26317         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26318         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26319                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26320                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26321         }
26322         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26323         CHECK_ACCESS(logger_ptr);
26324         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26325         if (logger_conv.free == LDKLogger_JCalls_free) {
26326                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26327                 LDKLogger_JCalls_cloned(&logger_conv);
26328         }
26329         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);
26330         int64_tArray ret_arr = NULL;
26331         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26332         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26333         for (size_t n = 0; n < ret_var.datalen; n++) {
26334                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26335                 *ret_conv_39_conv = ret_var.data[n];
26336                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26337         }
26338         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26339         FREE(ret_var.data);
26340         return ret_arr;
26341 }
26342
26343 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) {
26344         LDKChannelMonitor this_arg_conv;
26345         this_arg_conv.inner = (void*)(this_arg & (~1));
26346         this_arg_conv.is_owned = false;
26347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26348         unsigned char txid_arr[32];
26349         CHECK((*env)->GetArrayLength(env, txid) == 32);
26350         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
26351         unsigned char (*txid_ref)[32] = &txid_arr;
26352         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26353         CHECK_ACCESS(broadcaster_ptr);
26354         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26355         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26356                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26357                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26358         }
26359         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26360         CHECK_ACCESS(fee_estimator_ptr);
26361         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26362         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26363                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26364                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26365         }
26366         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26367         CHECK_ACCESS(logger_ptr);
26368         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26369         if (logger_conv.free == LDKLogger_JCalls_free) {
26370                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26371                 LDKLogger_JCalls_cloned(&logger_conv);
26372         }
26373         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
26374 }
26375
26376 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) {
26377         LDKChannelMonitor this_arg_conv;
26378         this_arg_conv.inner = (void*)(this_arg & (~1));
26379         this_arg_conv.is_owned = false;
26380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26381         unsigned char header_arr[80];
26382         CHECK((*env)->GetArrayLength(env, header) == 80);
26383         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26384         unsigned char (*header_ref)[80] = &header_arr;
26385         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26386         CHECK_ACCESS(broadcaster_ptr);
26387         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26388         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26389                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26390                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26391         }
26392         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26393         CHECK_ACCESS(fee_estimator_ptr);
26394         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26395         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26396                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26397                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26398         }
26399         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26400         CHECK_ACCESS(logger_ptr);
26401         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26402         if (logger_conv.free == LDKLogger_JCalls_free) {
26403                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26404                 LDKLogger_JCalls_cloned(&logger_conv);
26405         }
26406         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26407         int64_tArray ret_arr = NULL;
26408         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26409         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26410         for (size_t n = 0; n < ret_var.datalen; n++) {
26411                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26412                 *ret_conv_39_conv = ret_var.data[n];
26413                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26414         }
26415         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26416         FREE(ret_var.data);
26417         return ret_arr;
26418 }
26419
26420 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
26421         LDKChannelMonitor this_arg_conv;
26422         this_arg_conv.inner = (void*)(this_arg & (~1));
26423         this_arg_conv.is_owned = false;
26424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26425         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
26426         jobjectArray ret_arr = NULL;
26427         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26428         ;
26429         for (size_t i = 0; i < ret_var.datalen; i++) {
26430                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
26431                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
26432                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26433         }
26434         
26435         FREE(ret_var.data);
26436         return ret_arr;
26437 }
26438
26439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
26440         LDKChannelMonitor this_arg_conv;
26441         this_arg_conv.inner = (void*)(this_arg & (~1));
26442         this_arg_conv.is_owned = false;
26443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26444         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
26445         int64_t ret_ref = 0;
26446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26449         ret_ref = (uintptr_t)ret_var.inner;
26450         if (ret_var.is_owned) {
26451                 ret_ref |= 1;
26452         }
26453         return ret_ref;
26454 }
26455
26456 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
26457         LDKChannelMonitor this_arg_conv;
26458         this_arg_conv.inner = (void*)(this_arg & (~1));
26459         this_arg_conv.is_owned = false;
26460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26461         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
26462         int64_tArray ret_arr = NULL;
26463         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26464         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26465         for (size_t j = 0; j < ret_var.datalen; j++) {
26466                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26467                 *ret_conv_9_copy = ret_var.data[j];
26468                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26469                 ret_arr_ptr[j] = ret_conv_9_ref;
26470         }
26471         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26472         FREE(ret_var.data);
26473         return ret_arr;
26474 }
26475
26476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
26477         LDKu8slice ser_ref;
26478         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26479         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26480         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
26481         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
26482         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
26483         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
26484         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
26485         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26486         return (int64_t)ret_conv;
26487 }
26488
26489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26490         LDKOutPoint this_obj_conv;
26491         this_obj_conv.inner = (void*)(this_obj & (~1));
26492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26494         OutPoint_free(this_obj_conv);
26495 }
26496
26497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26498         LDKOutPoint this_ptr_conv;
26499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26500         this_ptr_conv.is_owned = false;
26501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26502         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
26504         return ret_arr;
26505 }
26506
26507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26508         LDKOutPoint this_ptr_conv;
26509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26510         this_ptr_conv.is_owned = false;
26511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26512         LDKThirtyTwoBytes val_ref;
26513         CHECK((*env)->GetArrayLength(env, val) == 32);
26514         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26515         OutPoint_set_txid(&this_ptr_conv, val_ref);
26516 }
26517
26518 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26519         LDKOutPoint this_ptr_conv;
26520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26521         this_ptr_conv.is_owned = false;
26522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26523         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
26524         return ret_conv;
26525 }
26526
26527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26528         LDKOutPoint this_ptr_conv;
26529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26530         this_ptr_conv.is_owned = false;
26531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26532         OutPoint_set_index(&this_ptr_conv, val);
26533 }
26534
26535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
26536         LDKThirtyTwoBytes txid_arg_ref;
26537         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26538         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26539         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
26540         int64_t ret_ref = 0;
26541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26544         ret_ref = (uintptr_t)ret_var.inner;
26545         if (ret_var.is_owned) {
26546                 ret_ref |= 1;
26547         }
26548         return ret_ref;
26549 }
26550
26551 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
26552         LDKOutPoint ret_var = OutPoint_clone(arg);
26553 int64_t ret_ref = 0;
26554 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26555 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26556 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26557 ret_ref = (uintptr_t)ret_var.inner;
26558 if (ret_var.is_owned) {
26559         ret_ref |= 1;
26560 }
26561         return ret_ref;
26562 }
26563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26564         LDKOutPoint arg_conv;
26565         arg_conv.inner = (void*)(arg & (~1));
26566         arg_conv.is_owned = false;
26567         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26568         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
26569         return ret_conv;
26570 }
26571
26572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26573         LDKOutPoint orig_conv;
26574         orig_conv.inner = (void*)(orig & (~1));
26575         orig_conv.is_owned = false;
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26577         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
26578         int64_t ret_ref = 0;
26579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26582         ret_ref = (uintptr_t)ret_var.inner;
26583         if (ret_var.is_owned) {
26584                 ret_ref |= 1;
26585         }
26586         return ret_ref;
26587 }
26588
26589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26590         LDKOutPoint a_conv;
26591         a_conv.inner = (void*)(a & (~1));
26592         a_conv.is_owned = false;
26593         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26594         LDKOutPoint b_conv;
26595         b_conv.inner = (void*)(b & (~1));
26596         b_conv.is_owned = false;
26597         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26598         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
26599         return ret_conv;
26600 }
26601
26602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26603         LDKOutPoint o_conv;
26604         o_conv.inner = (void*)(o & (~1));
26605         o_conv.is_owned = false;
26606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26607         int64_t ret_conv = OutPoint_hash(&o_conv);
26608         return ret_conv;
26609 }
26610
26611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26612         LDKOutPoint this_arg_conv;
26613         this_arg_conv.inner = (void*)(this_arg & (~1));
26614         this_arg_conv.is_owned = false;
26615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26616         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26617         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
26618         return ret_arr;
26619 }
26620
26621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
26622         LDKOutPoint obj_conv;
26623         obj_conv.inner = (void*)(obj & (~1));
26624         obj_conv.is_owned = false;
26625         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26626         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
26627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26629         CVec_u8Z_free(ret_var);
26630         return ret_arr;
26631 }
26632
26633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26634         LDKu8slice ser_ref;
26635         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26636         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26637         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
26638         *ret_conv = OutPoint_read(ser_ref);
26639         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26640         return (int64_t)ret_conv;
26641 }
26642
26643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26644         LDKDelayedPaymentOutputDescriptor this_obj_conv;
26645         this_obj_conv.inner = (void*)(this_obj & (~1));
26646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26648         DelayedPaymentOutputDescriptor_free(this_obj_conv);
26649 }
26650
26651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26652         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26654         this_ptr_conv.is_owned = false;
26655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26656         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26657         int64_t ret_ref = 0;
26658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26661         ret_ref = (uintptr_t)ret_var.inner;
26662         if (ret_var.is_owned) {
26663                 ret_ref |= 1;
26664         }
26665         return ret_ref;
26666 }
26667
26668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26669         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26671         this_ptr_conv.is_owned = false;
26672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26673         LDKOutPoint val_conv;
26674         val_conv.inner = (void*)(val & (~1));
26675         val_conv.is_owned = (val & 1) || (val == 0);
26676         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26677         val_conv = OutPoint_clone(&val_conv);
26678         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26679 }
26680
26681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26682         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26684         this_ptr_conv.is_owned = false;
26685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26686         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
26688         return ret_arr;
26689 }
26690
26691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26692         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26694         this_ptr_conv.is_owned = false;
26695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26696         LDKPublicKey val_ref;
26697         CHECK((*env)->GetArrayLength(env, val) == 33);
26698         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26699         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
26700 }
26701
26702 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26703         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26705         this_ptr_conv.is_owned = false;
26706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26707         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
26708         return ret_conv;
26709 }
26710
26711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26712         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26714         this_ptr_conv.is_owned = false;
26715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26716         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
26717 }
26718
26719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26720         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26722         this_ptr_conv.is_owned = false;
26723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26724         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26725         CHECK_ACCESS(val_ptr);
26726         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26727         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26728         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26729 }
26730
26731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26732         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26734         this_ptr_conv.is_owned = false;
26735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26736         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
26738         return ret_arr;
26739 }
26740
26741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26742         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26744         this_ptr_conv.is_owned = false;
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26746         LDKPublicKey val_ref;
26747         CHECK((*env)->GetArrayLength(env, val) == 33);
26748         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26749         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
26750 }
26751
26752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26753         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26755         this_ptr_conv.is_owned = false;
26756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26757         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26758         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26759         return ret_arr;
26760 }
26761
26762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26763         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26765         this_ptr_conv.is_owned = false;
26766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26767         LDKThirtyTwoBytes val_ref;
26768         CHECK((*env)->GetArrayLength(env, val) == 32);
26769         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26770         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26771 }
26772
26773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26774         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26776         this_ptr_conv.is_owned = false;
26777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26778         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26779         return ret_conv;
26780 }
26781
26782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26783         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26785         this_ptr_conv.is_owned = false;
26786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26787         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26788 }
26789
26790 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) {
26791         LDKOutPoint outpoint_arg_conv;
26792         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26793         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26794         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26795         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26796         LDKPublicKey per_commitment_point_arg_ref;
26797         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
26798         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
26799         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26800         CHECK_ACCESS(output_arg_ptr);
26801         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26802         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26803         LDKPublicKey revocation_pubkey_arg_ref;
26804         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
26805         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
26806         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26807         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26808         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26809         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);
26810         int64_t ret_ref = 0;
26811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26814         ret_ref = (uintptr_t)ret_var.inner;
26815         if (ret_var.is_owned) {
26816                 ret_ref |= 1;
26817         }
26818         return ret_ref;
26819 }
26820
26821 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
26822         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
26823 int64_t ret_ref = 0;
26824 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26825 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26826 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26827 ret_ref = (uintptr_t)ret_var.inner;
26828 if (ret_var.is_owned) {
26829         ret_ref |= 1;
26830 }
26831         return ret_ref;
26832 }
26833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26834         LDKDelayedPaymentOutputDescriptor arg_conv;
26835         arg_conv.inner = (void*)(arg & (~1));
26836         arg_conv.is_owned = false;
26837         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26838         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
26839         return ret_conv;
26840 }
26841
26842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26843         LDKDelayedPaymentOutputDescriptor orig_conv;
26844         orig_conv.inner = (void*)(orig & (~1));
26845         orig_conv.is_owned = false;
26846         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26847         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
26848         int64_t ret_ref = 0;
26849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26852         ret_ref = (uintptr_t)ret_var.inner;
26853         if (ret_var.is_owned) {
26854                 ret_ref |= 1;
26855         }
26856         return ret_ref;
26857 }
26858
26859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26860         LDKDelayedPaymentOutputDescriptor obj_conv;
26861         obj_conv.inner = (void*)(obj & (~1));
26862         obj_conv.is_owned = false;
26863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26864         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
26865         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26866         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26867         CVec_u8Z_free(ret_var);
26868         return ret_arr;
26869 }
26870
26871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26872         LDKu8slice ser_ref;
26873         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26874         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26875         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
26876         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
26877         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26878         return (int64_t)ret_conv;
26879 }
26880
26881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26882         LDKStaticPaymentOutputDescriptor this_obj_conv;
26883         this_obj_conv.inner = (void*)(this_obj & (~1));
26884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26886         StaticPaymentOutputDescriptor_free(this_obj_conv);
26887 }
26888
26889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26890         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26892         this_ptr_conv.is_owned = false;
26893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26894         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26895         int64_t ret_ref = 0;
26896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26899         ret_ref = (uintptr_t)ret_var.inner;
26900         if (ret_var.is_owned) {
26901                 ret_ref |= 1;
26902         }
26903         return ret_ref;
26904 }
26905
26906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26907         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26909         this_ptr_conv.is_owned = false;
26910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26911         LDKOutPoint val_conv;
26912         val_conv.inner = (void*)(val & (~1));
26913         val_conv.is_owned = (val & 1) || (val == 0);
26914         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26915         val_conv = OutPoint_clone(&val_conv);
26916         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26917 }
26918
26919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26920         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26922         this_ptr_conv.is_owned = false;
26923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26924         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26925         CHECK_ACCESS(val_ptr);
26926         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26927         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26928         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26929 }
26930
26931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26932         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26934         this_ptr_conv.is_owned = false;
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26936         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26938         return ret_arr;
26939 }
26940
26941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26942         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26944         this_ptr_conv.is_owned = false;
26945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26946         LDKThirtyTwoBytes val_ref;
26947         CHECK((*env)->GetArrayLength(env, val) == 32);
26948         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26949         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26950 }
26951
26952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26953         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26955         this_ptr_conv.is_owned = false;
26956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26957         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26958         return ret_conv;
26959 }
26960
26961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26962         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26964         this_ptr_conv.is_owned = false;
26965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26966         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26967 }
26968
26969 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) {
26970         LDKOutPoint outpoint_arg_conv;
26971         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26972         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26973         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26974         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26975         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26976         CHECK_ACCESS(output_arg_ptr);
26977         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26978         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26979         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26980         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26981         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26982         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
26983         int64_t ret_ref = 0;
26984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26987         ret_ref = (uintptr_t)ret_var.inner;
26988         if (ret_var.is_owned) {
26989                 ret_ref |= 1;
26990         }
26991         return ret_ref;
26992 }
26993
26994 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
26995         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
26996 int64_t ret_ref = 0;
26997 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26998 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26999 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27000 ret_ref = (uintptr_t)ret_var.inner;
27001 if (ret_var.is_owned) {
27002         ret_ref |= 1;
27003 }
27004         return ret_ref;
27005 }
27006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27007         LDKStaticPaymentOutputDescriptor arg_conv;
27008         arg_conv.inner = (void*)(arg & (~1));
27009         arg_conv.is_owned = false;
27010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27011         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
27012         return ret_conv;
27013 }
27014
27015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27016         LDKStaticPaymentOutputDescriptor orig_conv;
27017         orig_conv.inner = (void*)(orig & (~1));
27018         orig_conv.is_owned = false;
27019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27020         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
27021         int64_t ret_ref = 0;
27022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27025         ret_ref = (uintptr_t)ret_var.inner;
27026         if (ret_var.is_owned) {
27027                 ret_ref |= 1;
27028         }
27029         return ret_ref;
27030 }
27031
27032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27033         LDKStaticPaymentOutputDescriptor obj_conv;
27034         obj_conv.inner = (void*)(obj & (~1));
27035         obj_conv.is_owned = false;
27036         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27037         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
27038         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27039         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27040         CVec_u8Z_free(ret_var);
27041         return ret_arr;
27042 }
27043
27044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27045         LDKu8slice ser_ref;
27046         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27047         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27048         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
27049         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
27050         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27051         return (int64_t)ret_conv;
27052 }
27053
27054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27055         if ((this_ptr & 1) != 0) return;
27056         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27057         CHECK_ACCESS(this_ptr_ptr);
27058         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
27059         FREE((void*)this_ptr);
27060         SpendableOutputDescriptor_free(this_ptr_conv);
27061 }
27062
27063 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27064         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27065         *ret_copy = SpendableOutputDescriptor_clone(arg);
27066 int64_t ret_ref = (uintptr_t)ret_copy;
27067         return ret_ref;
27068 }
27069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27070         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
27071         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
27072         return ret_conv;
27073 }
27074
27075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27076         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
27077         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27078         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27079         int64_t ret_ref = (uintptr_t)ret_copy;
27080         return ret_ref;
27081 }
27082
27083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27084         LDKOutPoint outpoint_conv;
27085         outpoint_conv.inner = (void*)(outpoint & (~1));
27086         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
27087         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27088         outpoint_conv = OutPoint_clone(&outpoint_conv);
27089         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
27090         CHECK_ACCESS(output_ptr);
27091         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27092         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
27093         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27094         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27095         int64_t ret_ref = (uintptr_t)ret_copy;
27096         return ret_ref;
27097 }
27098
27099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27100         LDKDelayedPaymentOutputDescriptor a_conv;
27101         a_conv.inner = (void*)(a & (~1));
27102         a_conv.is_owned = (a & 1) || (a == 0);
27103         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27104         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27105         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27106         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27107         int64_t ret_ref = (uintptr_t)ret_copy;
27108         return ret_ref;
27109 }
27110
27111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27112         LDKStaticPaymentOutputDescriptor a_conv;
27113         a_conv.inner = (void*)(a & (~1));
27114         a_conv.is_owned = (a & 1) || (a == 0);
27115         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27116         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27117         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27118         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27119         int64_t ret_ref = (uintptr_t)ret_copy;
27120         return ret_ref;
27121 }
27122
27123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27124         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
27125         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27126         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27127         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27128         CVec_u8Z_free(ret_var);
27129         return ret_arr;
27130 }
27131
27132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27133         LDKu8slice ser_ref;
27134         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27135         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27136         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
27137         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
27138         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27139         return (int64_t)ret_conv;
27140 }
27141
27142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27143         if ((this_ptr & 1) != 0) return;
27144         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27145         CHECK_ACCESS(this_ptr_ptr);
27146         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
27147         FREE((void*)this_ptr);
27148         BaseSign_free(this_ptr_conv);
27149 }
27150
27151 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
27152         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27153         *ret_ret = Sign_clone(arg);
27154         return (int64_t)ret_ret;
27155 }
27156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27157         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27158         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27159         LDKSign* arg_conv = (LDKSign*)arg_ptr;
27160         int64_t ret_conv = Sign_clone_ptr(arg_conv);
27161         return ret_conv;
27162 }
27163
27164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27165         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
27166         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
27167         LDKSign* orig_conv = (LDKSign*)orig_ptr;
27168         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27169         *ret_ret = Sign_clone(orig_conv);
27170         return (int64_t)ret_ret;
27171 }
27172
27173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27174         if ((this_ptr & 1) != 0) return;
27175         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27176         CHECK_ACCESS(this_ptr_ptr);
27177         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
27178         FREE((void*)this_ptr);
27179         Sign_free(this_ptr_conv);
27180 }
27181
27182 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27183         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
27184         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
27185         return ret_conv;
27186 }
27187
27188 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
27189         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
27190         return ret_conv;
27191 }
27192
27193 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
27194         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
27195         return ret_conv;
27196 }
27197
27198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27199         if ((this_ptr & 1) != 0) return;
27200         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27201         CHECK_ACCESS(this_ptr_ptr);
27202         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
27203         FREE((void*)this_ptr);
27204         KeysInterface_free(this_ptr_conv);
27205 }
27206
27207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27208         LDKInMemorySigner this_obj_conv;
27209         this_obj_conv.inner = (void*)(this_obj & (~1));
27210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27212         InMemorySigner_free(this_obj_conv);
27213 }
27214
27215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27216         LDKInMemorySigner this_ptr_conv;
27217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27218         this_ptr_conv.is_owned = false;
27219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
27222         return ret_arr;
27223 }
27224
27225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27226         LDKInMemorySigner this_ptr_conv;
27227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27228         this_ptr_conv.is_owned = false;
27229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27230         LDKSecretKey val_ref;
27231         CHECK((*env)->GetArrayLength(env, val) == 32);
27232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27233         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
27234 }
27235
27236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27237         LDKInMemorySigner this_ptr_conv;
27238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27239         this_ptr_conv.is_owned = false;
27240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
27243         return ret_arr;
27244 }
27245
27246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27247         LDKInMemorySigner this_ptr_conv;
27248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27249         this_ptr_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27251         LDKSecretKey val_ref;
27252         CHECK((*env)->GetArrayLength(env, val) == 32);
27253         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27254         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
27255 }
27256
27257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27258         LDKInMemorySigner this_ptr_conv;
27259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27260         this_ptr_conv.is_owned = false;
27261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27262         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
27264         return ret_arr;
27265 }
27266
27267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27268         LDKInMemorySigner this_ptr_conv;
27269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27270         this_ptr_conv.is_owned = false;
27271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27272         LDKSecretKey val_ref;
27273         CHECK((*env)->GetArrayLength(env, val) == 32);
27274         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27275         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
27276 }
27277
27278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27279         LDKInMemorySigner this_ptr_conv;
27280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27281         this_ptr_conv.is_owned = false;
27282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27283         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
27285         return ret_arr;
27286 }
27287
27288 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) {
27289         LDKInMemorySigner 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         LDKSecretKey val_ref;
27294         CHECK((*env)->GetArrayLength(env, val) == 32);
27295         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27296         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
27297 }
27298
27299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27300         LDKInMemorySigner this_ptr_conv;
27301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27302         this_ptr_conv.is_owned = false;
27303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27304         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27305         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
27306         return ret_arr;
27307 }
27308
27309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27310         LDKInMemorySigner this_ptr_conv;
27311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27312         this_ptr_conv.is_owned = false;
27313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27314         LDKSecretKey val_ref;
27315         CHECK((*env)->GetArrayLength(env, val) == 32);
27316         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27317         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
27318 }
27319
27320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
27321         LDKInMemorySigner this_ptr_conv;
27322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27323         this_ptr_conv.is_owned = false;
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27325         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
27327         return ret_arr;
27328 }
27329
27330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27331         LDKInMemorySigner this_ptr_conv;
27332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27333         this_ptr_conv.is_owned = false;
27334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27335         LDKThirtyTwoBytes val_ref;
27336         CHECK((*env)->GetArrayLength(env, val) == 32);
27337         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27338         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
27339 }
27340
27341 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
27342         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
27343 int64_t ret_ref = 0;
27344 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27345 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27346 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27347 ret_ref = (uintptr_t)ret_var.inner;
27348 if (ret_var.is_owned) {
27349         ret_ref |= 1;
27350 }
27351         return ret_ref;
27352 }
27353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27354         LDKInMemorySigner arg_conv;
27355         arg_conv.inner = (void*)(arg & (~1));
27356         arg_conv.is_owned = false;
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27358         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
27359         return ret_conv;
27360 }
27361
27362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27363         LDKInMemorySigner orig_conv;
27364         orig_conv.inner = (void*)(orig & (~1));
27365         orig_conv.is_owned = false;
27366         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27367         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
27368         int64_t ret_ref = 0;
27369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27372         ret_ref = (uintptr_t)ret_var.inner;
27373         if (ret_var.is_owned) {
27374                 ret_ref |= 1;
27375         }
27376         return ret_ref;
27377 }
27378
27379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, int8_tArray node_secret, int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
27380         LDKSecretKey node_secret_ref;
27381         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
27382         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
27383         LDKSecretKey funding_key_ref;
27384         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
27385         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
27386         LDKSecretKey revocation_base_key_ref;
27387         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
27388         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
27389         LDKSecretKey payment_key_ref;
27390         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
27391         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
27392         LDKSecretKey delayed_payment_base_key_ref;
27393         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
27394         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
27395         LDKSecretKey htlc_base_key_ref;
27396         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
27397         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
27398         LDKThirtyTwoBytes commitment_seed_ref;
27399         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
27400         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
27401         LDKThirtyTwoBytes channel_keys_id_ref;
27402         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
27403         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
27404         LDKInMemorySigner ret_var = InMemorySigner_new(node_secret_ref, funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
27405         int64_t ret_ref = 0;
27406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27409         ret_ref = (uintptr_t)ret_var.inner;
27410         if (ret_var.is_owned) {
27411                 ret_ref |= 1;
27412         }
27413         return ret_ref;
27414 }
27415
27416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
27417         LDKInMemorySigner this_arg_conv;
27418         this_arg_conv.inner = (void*)(this_arg & (~1));
27419         this_arg_conv.is_owned = false;
27420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27421         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
27422         int64_t ret_ref = 0;
27423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27426         ret_ref = (uintptr_t)ret_var.inner;
27427         if (ret_var.is_owned) {
27428                 ret_ref |= 1;
27429         }
27430         return ret_ref;
27431 }
27432
27433 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27434         LDKInMemorySigner this_arg_conv;
27435         this_arg_conv.inner = (void*)(this_arg & (~1));
27436         this_arg_conv.is_owned = false;
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27438         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
27439         return ret_conv;
27440 }
27441
27442 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27443         LDKInMemorySigner this_arg_conv;
27444         this_arg_conv.inner = (void*)(this_arg & (~1));
27445         this_arg_conv.is_owned = false;
27446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27447         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
27448         return ret_conv;
27449 }
27450
27451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
27452         LDKInMemorySigner this_arg_conv;
27453         this_arg_conv.inner = (void*)(this_arg & (~1));
27454         this_arg_conv.is_owned = false;
27455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27456         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
27457         return ret_conv;
27458 }
27459
27460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
27461         LDKInMemorySigner this_arg_conv;
27462         this_arg_conv.inner = (void*)(this_arg & (~1));
27463         this_arg_conv.is_owned = false;
27464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27465         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
27466         int64_t ret_ref = 0;
27467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27470         ret_ref = (uintptr_t)ret_var.inner;
27471         if (ret_var.is_owned) {
27472                 ret_ref |= 1;
27473         }
27474         return ret_ref;
27475 }
27476
27477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
27478         LDKInMemorySigner this_arg_conv;
27479         this_arg_conv.inner = (void*)(this_arg & (~1));
27480         this_arg_conv.is_owned = false;
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27482         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
27483         int64_t ret_ref = 0;
27484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27487         ret_ref = (uintptr_t)ret_var.inner;
27488         if (ret_var.is_owned) {
27489                 ret_ref |= 1;
27490         }
27491         return ret_ref;
27492 }
27493
27494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
27495         LDKInMemorySigner this_arg_conv;
27496         this_arg_conv.inner = (void*)(this_arg & (~1));
27497         this_arg_conv.is_owned = false;
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27499         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
27500         return ret_conv;
27501 }
27502
27503 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) {
27504         LDKInMemorySigner this_arg_conv;
27505         this_arg_conv.inner = (void*)(this_arg & (~1));
27506         this_arg_conv.is_owned = false;
27507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27508         LDKTransaction spend_tx_ref;
27509         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27510         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27511         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27512         spend_tx_ref.data_is_owned = true;
27513         LDKStaticPaymentOutputDescriptor descriptor_conv;
27514         descriptor_conv.inner = (void*)(descriptor & (~1));
27515         descriptor_conv.is_owned = false;
27516         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27517         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27518         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27519         return (int64_t)ret_conv;
27520 }
27521
27522 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) {
27523         LDKInMemorySigner this_arg_conv;
27524         this_arg_conv.inner = (void*)(this_arg & (~1));
27525         this_arg_conv.is_owned = false;
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27527         LDKTransaction spend_tx_ref;
27528         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27529         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27530         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27531         spend_tx_ref.data_is_owned = true;
27532         LDKDelayedPaymentOutputDescriptor descriptor_conv;
27533         descriptor_conv.inner = (void*)(descriptor & (~1));
27534         descriptor_conv.is_owned = false;
27535         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27536         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27537         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27538         return (int64_t)ret_conv;
27539 }
27540
27541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
27542         LDKInMemorySigner this_arg_conv;
27543         this_arg_conv.inner = (void*)(this_arg & (~1));
27544         this_arg_conv.is_owned = false;
27545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27546         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
27547         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
27548         return (int64_t)ret_ret;
27549 }
27550
27551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
27552         LDKInMemorySigner this_arg_conv;
27553         this_arg_conv.inner = (void*)(this_arg & (~1));
27554         this_arg_conv.is_owned = false;
27555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27556         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27557         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
27558         return (int64_t)ret_ret;
27559 }
27560
27561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
27562         LDKInMemorySigner obj_conv;
27563         obj_conv.inner = (void*)(obj & (~1));
27564         obj_conv.is_owned = false;
27565         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27566         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
27567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27569         CVec_u8Z_free(ret_var);
27570         return ret_arr;
27571 }
27572
27573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
27574         LDKu8slice ser_ref;
27575         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27576         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27577         LDKSecretKey arg_ref;
27578         CHECK((*env)->GetArrayLength(env, arg) == 32);
27579         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
27580         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
27581         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
27582         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27583         return (int64_t)ret_conv;
27584 }
27585
27586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27587         LDKKeysManager this_obj_conv;
27588         this_obj_conv.inner = (void*)(this_obj & (~1));
27589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27591         KeysManager_free(this_obj_conv);
27592 }
27593
27594 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) {
27595         unsigned char seed_arr[32];
27596         CHECK((*env)->GetArrayLength(env, seed) == 32);
27597         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27598         unsigned char (*seed_ref)[32] = &seed_arr;
27599         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
27600         int64_t ret_ref = 0;
27601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27604         ret_ref = (uintptr_t)ret_var.inner;
27605         if (ret_var.is_owned) {
27606                 ret_ref |= 1;
27607         }
27608         return ret_ref;
27609 }
27610
27611 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) {
27612         LDKKeysManager this_arg_conv;
27613         this_arg_conv.inner = (void*)(this_arg & (~1));
27614         this_arg_conv.is_owned = false;
27615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27616         unsigned char params_arr[32];
27617         CHECK((*env)->GetArrayLength(env, params) == 32);
27618         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27619         unsigned char (*params_ref)[32] = &params_arr;
27620         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27621         int64_t ret_ref = 0;
27622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27625         ret_ref = (uintptr_t)ret_var.inner;
27626         if (ret_var.is_owned) {
27627                 ret_ref |= 1;
27628         }
27629         return ret_ref;
27630 }
27631
27632 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) {
27633         LDKKeysManager this_arg_conv;
27634         this_arg_conv.inner = (void*)(this_arg & (~1));
27635         this_arg_conv.is_owned = false;
27636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27637         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27638         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27639         if (descriptors_constr.datalen > 0)
27640                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27641         else
27642                 descriptors_constr.data = NULL;
27643         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27644         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27645                 int64_t descriptors_conv_27 = descriptors_vals[b];
27646                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27647                 CHECK_ACCESS(descriptors_conv_27_ptr);
27648                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27649                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27650                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27651         }
27652         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27653         LDKCVec_TxOutZ outputs_constr;
27654         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27655         if (outputs_constr.datalen > 0)
27656                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27657         else
27658                 outputs_constr.data = NULL;
27659         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27660         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27661                 int64_t outputs_conv_7 = outputs_vals[h];
27662                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27663                 CHECK_ACCESS(outputs_conv_7_ptr);
27664                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27665                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27666                 outputs_constr.data[h] = outputs_conv_7_conv;
27667         }
27668         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27669         LDKCVec_u8Z change_destination_script_ref;
27670         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27671         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27672         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27673         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27674         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27675         return (int64_t)ret_conv;
27676 }
27677
27678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27679         LDKKeysManager this_arg_conv;
27680         this_arg_conv.inner = (void*)(this_arg & (~1));
27681         this_arg_conv.is_owned = false;
27682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27683         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27684         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
27685         return (int64_t)ret_ret;
27686 }
27687
27688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27689         LDKPhantomKeysManager this_obj_conv;
27690         this_obj_conv.inner = (void*)(this_obj & (~1));
27691         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27693         PhantomKeysManager_free(this_obj_conv);
27694 }
27695
27696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27697         LDKPhantomKeysManager this_arg_conv;
27698         this_arg_conv.inner = (void*)(this_arg & (~1));
27699         this_arg_conv.is_owned = false;
27700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27701         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27702         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
27703         return (int64_t)ret_ret;
27704 }
27705
27706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
27707         unsigned char seed_arr[32];
27708         CHECK((*env)->GetArrayLength(env, seed) == 32);
27709         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27710         unsigned char (*seed_ref)[32] = &seed_arr;
27711         unsigned char cross_node_seed_arr[32];
27712         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
27713         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
27714         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
27715         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
27716         int64_t ret_ref = 0;
27717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27720         ret_ref = (uintptr_t)ret_var.inner;
27721         if (ret_var.is_owned) {
27722                 ret_ref |= 1;
27723         }
27724         return ret_ref;
27725 }
27726
27727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1spend_1spendable_1outputs(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
27728         LDKPhantomKeysManager this_arg_conv;
27729         this_arg_conv.inner = (void*)(this_arg & (~1));
27730         this_arg_conv.is_owned = false;
27731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27732         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27733         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27734         if (descriptors_constr.datalen > 0)
27735                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27736         else
27737                 descriptors_constr.data = NULL;
27738         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27739         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27740                 int64_t descriptors_conv_27 = descriptors_vals[b];
27741                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27742                 CHECK_ACCESS(descriptors_conv_27_ptr);
27743                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27744                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27745                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27746         }
27747         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27748         LDKCVec_TxOutZ outputs_constr;
27749         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27750         if (outputs_constr.datalen > 0)
27751                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27752         else
27753                 outputs_constr.data = NULL;
27754         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27755         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27756                 int64_t outputs_conv_7 = outputs_vals[h];
27757                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27758                 CHECK_ACCESS(outputs_conv_7_ptr);
27759                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27760                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27761                 outputs_constr.data[h] = outputs_conv_7_conv;
27762         }
27763         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27764         LDKCVec_u8Z change_destination_script_ref;
27765         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27766         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27767         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27768         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27769         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27770         return (int64_t)ret_conv;
27771 }
27772
27773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1derive_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
27774         LDKPhantomKeysManager this_arg_conv;
27775         this_arg_conv.inner = (void*)(this_arg & (~1));
27776         this_arg_conv.is_owned = false;
27777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27778         unsigned char params_arr[32];
27779         CHECK((*env)->GetArrayLength(env, params) == 32);
27780         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27781         unsigned char (*params_ref)[32] = &params_arr;
27782         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27783         int64_t ret_ref = 0;
27784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27787         ret_ref = (uintptr_t)ret_var.inner;
27788         if (ret_var.is_owned) {
27789                 ret_ref |= 1;
27790         }
27791         return ret_ref;
27792 }
27793
27794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27795         LDKChannelManager this_obj_conv;
27796         this_obj_conv.inner = (void*)(this_obj & (~1));
27797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27799         ChannelManager_free(this_obj_conv);
27800 }
27801
27802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27803         LDKChainParameters this_obj_conv;
27804         this_obj_conv.inner = (void*)(this_obj & (~1));
27805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27807         ChainParameters_free(this_obj_conv);
27808 }
27809
27810 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
27811         LDKChainParameters this_ptr_conv;
27812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27813         this_ptr_conv.is_owned = false;
27814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27815         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
27816         return ret_conv;
27817 }
27818
27819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27820         LDKChainParameters this_ptr_conv;
27821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27822         this_ptr_conv.is_owned = false;
27823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27824         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
27825         ChainParameters_set_network(&this_ptr_conv, val_conv);
27826 }
27827
27828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
27829         LDKChainParameters this_ptr_conv;
27830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27831         this_ptr_conv.is_owned = false;
27832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27833         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
27834         int64_t ret_ref = 0;
27835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27838         ret_ref = (uintptr_t)ret_var.inner;
27839         if (ret_var.is_owned) {
27840                 ret_ref |= 1;
27841         }
27842         return ret_ref;
27843 }
27844
27845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27846         LDKChainParameters this_ptr_conv;
27847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27848         this_ptr_conv.is_owned = false;
27849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27850         LDKBestBlock val_conv;
27851         val_conv.inner = (void*)(val & (~1));
27852         val_conv.is_owned = (val & 1) || (val == 0);
27853         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27854         val_conv = BestBlock_clone(&val_conv);
27855         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
27856 }
27857
27858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
27859         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
27860         LDKBestBlock best_block_arg_conv;
27861         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
27862         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
27863         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
27864         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
27865         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
27866         int64_t ret_ref = 0;
27867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27870         ret_ref = (uintptr_t)ret_var.inner;
27871         if (ret_var.is_owned) {
27872                 ret_ref |= 1;
27873         }
27874         return ret_ref;
27875 }
27876
27877 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
27878         LDKChainParameters ret_var = ChainParameters_clone(arg);
27879 int64_t ret_ref = 0;
27880 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27881 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27882 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27883 ret_ref = (uintptr_t)ret_var.inner;
27884 if (ret_var.is_owned) {
27885         ret_ref |= 1;
27886 }
27887         return ret_ref;
27888 }
27889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27890         LDKChainParameters arg_conv;
27891         arg_conv.inner = (void*)(arg & (~1));
27892         arg_conv.is_owned = false;
27893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27894         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
27895         return ret_conv;
27896 }
27897
27898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27899         LDKChainParameters orig_conv;
27900         orig_conv.inner = (void*)(orig & (~1));
27901         orig_conv.is_owned = false;
27902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27903         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
27904         int64_t ret_ref = 0;
27905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27908         ret_ref = (uintptr_t)ret_var.inner;
27909         if (ret_var.is_owned) {
27910                 ret_ref |= 1;
27911         }
27912         return ret_ref;
27913 }
27914
27915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27916         LDKCounterpartyForwardingInfo this_obj_conv;
27917         this_obj_conv.inner = (void*)(this_obj & (~1));
27918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27920         CounterpartyForwardingInfo_free(this_obj_conv);
27921 }
27922
27923 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27924         LDKCounterpartyForwardingInfo this_ptr_conv;
27925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27926         this_ptr_conv.is_owned = false;
27927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27928         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
27929         return ret_conv;
27930 }
27931
27932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27933         LDKCounterpartyForwardingInfo this_ptr_conv;
27934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27935         this_ptr_conv.is_owned = false;
27936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27937         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
27938 }
27939
27940 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27941         LDKCounterpartyForwardingInfo this_ptr_conv;
27942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27943         this_ptr_conv.is_owned = false;
27944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27945         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
27946         return ret_conv;
27947 }
27948
27949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27950         LDKCounterpartyForwardingInfo this_ptr_conv;
27951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27952         this_ptr_conv.is_owned = false;
27953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27954         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
27955 }
27956
27957 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27958         LDKCounterpartyForwardingInfo this_ptr_conv;
27959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27960         this_ptr_conv.is_owned = false;
27961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27962         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
27963         return ret_conv;
27964 }
27965
27966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27967         LDKCounterpartyForwardingInfo this_ptr_conv;
27968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27969         this_ptr_conv.is_owned = false;
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27971         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27972 }
27973
27974 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) {
27975         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
27976         int64_t ret_ref = 0;
27977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27980         ret_ref = (uintptr_t)ret_var.inner;
27981         if (ret_var.is_owned) {
27982                 ret_ref |= 1;
27983         }
27984         return ret_ref;
27985 }
27986
27987 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
27988         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
27989 int64_t ret_ref = 0;
27990 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27991 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27993 ret_ref = (uintptr_t)ret_var.inner;
27994 if (ret_var.is_owned) {
27995         ret_ref |= 1;
27996 }
27997         return ret_ref;
27998 }
27999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28000         LDKCounterpartyForwardingInfo arg_conv;
28001         arg_conv.inner = (void*)(arg & (~1));
28002         arg_conv.is_owned = false;
28003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28004         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
28005         return ret_conv;
28006 }
28007
28008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28009         LDKCounterpartyForwardingInfo orig_conv;
28010         orig_conv.inner = (void*)(orig & (~1));
28011         orig_conv.is_owned = false;
28012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28013         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
28014         int64_t ret_ref = 0;
28015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28018         ret_ref = (uintptr_t)ret_var.inner;
28019         if (ret_var.is_owned) {
28020                 ret_ref |= 1;
28021         }
28022         return ret_ref;
28023 }
28024
28025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28026         LDKChannelCounterparty this_obj_conv;
28027         this_obj_conv.inner = (void*)(this_obj & (~1));
28028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28030         ChannelCounterparty_free(this_obj_conv);
28031 }
28032
28033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28034         LDKChannelCounterparty this_ptr_conv;
28035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28036         this_ptr_conv.is_owned = false;
28037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28038         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28039         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
28040         return ret_arr;
28041 }
28042
28043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28044         LDKChannelCounterparty this_ptr_conv;
28045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28046         this_ptr_conv.is_owned = false;
28047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28048         LDKPublicKey val_ref;
28049         CHECK((*env)->GetArrayLength(env, val) == 33);
28050         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28051         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
28052 }
28053
28054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28055         LDKChannelCounterparty this_ptr_conv;
28056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28057         this_ptr_conv.is_owned = false;
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28059         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
28060         int64_t ret_ref = 0;
28061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28064         ret_ref = (uintptr_t)ret_var.inner;
28065         if (ret_var.is_owned) {
28066                 ret_ref |= 1;
28067         }
28068         return ret_ref;
28069 }
28070
28071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28072         LDKChannelCounterparty this_ptr_conv;
28073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28074         this_ptr_conv.is_owned = false;
28075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28076         LDKInitFeatures val_conv;
28077         val_conv.inner = (void*)(val & (~1));
28078         val_conv.is_owned = (val & 1) || (val == 0);
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28080         val_conv = InitFeatures_clone(&val_conv);
28081         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28082 }
28083
28084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28085         LDKChannelCounterparty this_ptr_conv;
28086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28087         this_ptr_conv.is_owned = false;
28088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28089         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28090         return ret_conv;
28091 }
28092
28093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28094         LDKChannelCounterparty this_ptr_conv;
28095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28096         this_ptr_conv.is_owned = false;
28097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28098         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28099 }
28100
28101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28102         LDKChannelCounterparty this_ptr_conv;
28103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28104         this_ptr_conv.is_owned = false;
28105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28106         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28107         int64_t ret_ref = 0;
28108         if ((uintptr_t)ret_var.inner > 4096) {
28109                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28110                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28112                 ret_ref = (uintptr_t)ret_var.inner;
28113                 if (ret_var.is_owned) {
28114                         ret_ref |= 1;
28115                 }
28116         }
28117         return ret_ref;
28118 }
28119
28120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28121         LDKChannelCounterparty this_ptr_conv;
28122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28123         this_ptr_conv.is_owned = false;
28124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28125         LDKCounterpartyForwardingInfo val_conv;
28126         val_conv.inner = (void*)(val & (~1));
28127         val_conv.is_owned = (val & 1) || (val == 0);
28128         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28129         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
28130         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
28131 }
28132
28133 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) {
28134         LDKPublicKey node_id_arg_ref;
28135         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
28136         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
28137         LDKInitFeatures features_arg_conv;
28138         features_arg_conv.inner = (void*)(features_arg & (~1));
28139         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28141         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28142         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
28143         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
28144         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
28145         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
28146         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
28147         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
28148         int64_t ret_ref = 0;
28149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28152         ret_ref = (uintptr_t)ret_var.inner;
28153         if (ret_var.is_owned) {
28154                 ret_ref |= 1;
28155         }
28156         return ret_ref;
28157 }
28158
28159 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
28160         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
28161 int64_t ret_ref = 0;
28162 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28163 CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
28166 if (ret_var.is_owned) {
28167         ret_ref |= 1;
28168 }
28169         return ret_ref;
28170 }
28171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28172         LDKChannelCounterparty arg_conv;
28173         arg_conv.inner = (void*)(arg & (~1));
28174         arg_conv.is_owned = false;
28175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28176         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
28177         return ret_conv;
28178 }
28179
28180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28181         LDKChannelCounterparty orig_conv;
28182         orig_conv.inner = (void*)(orig & (~1));
28183         orig_conv.is_owned = false;
28184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28185         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
28186         int64_t ret_ref = 0;
28187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28190         ret_ref = (uintptr_t)ret_var.inner;
28191         if (ret_var.is_owned) {
28192                 ret_ref |= 1;
28193         }
28194         return ret_ref;
28195 }
28196
28197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28198         LDKChannelDetails this_obj_conv;
28199         this_obj_conv.inner = (void*)(this_obj & (~1));
28200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28202         ChannelDetails_free(this_obj_conv);
28203 }
28204
28205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28206         LDKChannelDetails this_ptr_conv;
28207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28208         this_ptr_conv.is_owned = false;
28209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28210         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
28212         return ret_arr;
28213 }
28214
28215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28216         LDKChannelDetails this_ptr_conv;
28217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28218         this_ptr_conv.is_owned = false;
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         LDKThirtyTwoBytes val_ref;
28221         CHECK((*env)->GetArrayLength(env, val) == 32);
28222         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28223         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
28224 }
28225
28226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
28227         LDKChannelDetails this_ptr_conv;
28228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28229         this_ptr_conv.is_owned = false;
28230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28231         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
28232         int64_t ret_ref = 0;
28233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28236         ret_ref = (uintptr_t)ret_var.inner;
28237         if (ret_var.is_owned) {
28238                 ret_ref |= 1;
28239         }
28240         return ret_ref;
28241 }
28242
28243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28244         LDKChannelDetails this_ptr_conv;
28245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28246         this_ptr_conv.is_owned = false;
28247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28248         LDKChannelCounterparty val_conv;
28249         val_conv.inner = (void*)(val & (~1));
28250         val_conv.is_owned = (val & 1) || (val == 0);
28251         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28252         val_conv = ChannelCounterparty_clone(&val_conv);
28253         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
28254 }
28255
28256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
28257         LDKChannelDetails this_ptr_conv;
28258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28259         this_ptr_conv.is_owned = false;
28260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28261         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
28262         int64_t ret_ref = 0;
28263         if ((uintptr_t)ret_var.inner > 4096) {
28264                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28265                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28267                 ret_ref = (uintptr_t)ret_var.inner;
28268                 if (ret_var.is_owned) {
28269                         ret_ref |= 1;
28270                 }
28271         }
28272         return ret_ref;
28273 }
28274
28275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28276         LDKChannelDetails this_ptr_conv;
28277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28278         this_ptr_conv.is_owned = false;
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28280         LDKOutPoint val_conv;
28281         val_conv.inner = (void*)(val & (~1));
28282         val_conv.is_owned = (val & 1) || (val == 0);
28283         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28284         val_conv = OutPoint_clone(&val_conv);
28285         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
28286 }
28287
28288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
28289         LDKChannelDetails this_ptr_conv;
28290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28291         this_ptr_conv.is_owned = false;
28292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28293         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
28294         int64_t ret_ref = 0;
28295         if ((uintptr_t)ret_var.inner > 4096) {
28296                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28297                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28299                 ret_ref = (uintptr_t)ret_var.inner;
28300                 if (ret_var.is_owned) {
28301                         ret_ref |= 1;
28302                 }
28303         }
28304         return ret_ref;
28305 }
28306
28307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28308         LDKChannelDetails this_ptr_conv;
28309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28310         this_ptr_conv.is_owned = false;
28311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28312         LDKChannelTypeFeatures val_conv;
28313         val_conv.inner = (void*)(val & (~1));
28314         val_conv.is_owned = (val & 1) || (val == 0);
28315         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28316         val_conv = ChannelTypeFeatures_clone(&val_conv);
28317         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
28318 }
28319
28320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28321         LDKChannelDetails this_ptr_conv;
28322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28323         this_ptr_conv.is_owned = false;
28324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28325         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28326         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
28327         int64_t ret_ref = (uintptr_t)ret_copy;
28328         return ret_ref;
28329 }
28330
28331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28332         LDKChannelDetails this_ptr_conv;
28333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28334         this_ptr_conv.is_owned = false;
28335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28336         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28337         CHECK_ACCESS(val_ptr);
28338         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28339         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28340         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
28341 }
28342
28343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28344         LDKChannelDetails this_ptr_conv;
28345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28346         this_ptr_conv.is_owned = false;
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28348         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28349         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
28350         int64_t ret_ref = (uintptr_t)ret_copy;
28351         return ret_ref;
28352 }
28353
28354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28355         LDKChannelDetails this_ptr_conv;
28356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28357         this_ptr_conv.is_owned = false;
28358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28359         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28360         CHECK_ACCESS(val_ptr);
28361         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28362         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28363         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
28364 }
28365
28366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28367         LDKChannelDetails this_ptr_conv;
28368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28369         this_ptr_conv.is_owned = false;
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28371         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
28372         return ret_conv;
28373 }
28374
28375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28376         LDKChannelDetails this_ptr_conv;
28377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28378         this_ptr_conv.is_owned = false;
28379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28380         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
28381 }
28382
28383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28384         LDKChannelDetails this_ptr_conv;
28385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28386         this_ptr_conv.is_owned = false;
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28388         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28389         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
28390         int64_t ret_ref = (uintptr_t)ret_copy;
28391         return ret_ref;
28392 }
28393
28394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28395         LDKChannelDetails this_ptr_conv;
28396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28397         this_ptr_conv.is_owned = false;
28398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28399         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28400         CHECK_ACCESS(val_ptr);
28401         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28402         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28403         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
28404 }
28405
28406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28407         LDKChannelDetails this_ptr_conv;
28408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28409         this_ptr_conv.is_owned = false;
28410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28411         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
28412         return ret_conv;
28413 }
28414
28415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28416         LDKChannelDetails this_ptr_conv;
28417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28418         this_ptr_conv.is_owned = false;
28419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28420         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
28421 }
28422
28423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28424         LDKChannelDetails this_ptr_conv;
28425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28426         this_ptr_conv.is_owned = false;
28427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28428         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
28429         return ret_conv;
28430 }
28431
28432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28433         LDKChannelDetails this_ptr_conv;
28434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28435         this_ptr_conv.is_owned = false;
28436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28437         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
28438 }
28439
28440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28441         LDKChannelDetails this_ptr_conv;
28442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28443         this_ptr_conv.is_owned = false;
28444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28445         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
28446         return ret_conv;
28447 }
28448
28449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28450         LDKChannelDetails this_ptr_conv;
28451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28452         this_ptr_conv.is_owned = false;
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28454         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
28455 }
28456
28457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28458         LDKChannelDetails this_ptr_conv;
28459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28460         this_ptr_conv.is_owned = false;
28461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28462         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
28463         return ret_conv;
28464 }
28465
28466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28467         LDKChannelDetails this_ptr_conv;
28468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28469         this_ptr_conv.is_owned = false;
28470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28471         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
28472 }
28473
28474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
28475         LDKChannelDetails this_ptr_conv;
28476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28477         this_ptr_conv.is_owned = false;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28479         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
28480         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
28481         int64_t ret_ref = (uintptr_t)ret_copy;
28482         return ret_ref;
28483 }
28484
28485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28486         LDKChannelDetails this_ptr_conv;
28487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28488         this_ptr_conv.is_owned = false;
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28490         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28491         CHECK_ACCESS(val_ptr);
28492         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
28493         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
28494         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
28495 }
28496
28497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28498         LDKChannelDetails this_ptr_conv;
28499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28500         this_ptr_conv.is_owned = false;
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28502         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
28503         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
28504         int64_t ret_ref = (uintptr_t)ret_copy;
28505         return ret_ref;
28506 }
28507
28508 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) {
28509         LDKChannelDetails this_ptr_conv;
28510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28511         this_ptr_conv.is_owned = false;
28512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28513         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28514         CHECK_ACCESS(val_ptr);
28515         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
28516         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
28517         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
28518 }
28519
28520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
28521         LDKChannelDetails this_ptr_conv;
28522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28523         this_ptr_conv.is_owned = false;
28524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28525         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
28526         return ret_conv;
28527 }
28528
28529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28530         LDKChannelDetails this_ptr_conv;
28531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28532         this_ptr_conv.is_owned = false;
28533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28534         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
28535 }
28536
28537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
28538         LDKChannelDetails this_ptr_conv;
28539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28540         this_ptr_conv.is_owned = false;
28541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28542         jboolean ret_conv = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
28543         return ret_conv;
28544 }
28545
28546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28547         LDKChannelDetails this_ptr_conv;
28548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28549         this_ptr_conv.is_owned = false;
28550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28551         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
28552 }
28553
28554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
28555         LDKChannelDetails 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         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
28560         return ret_conv;
28561 }
28562
28563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28564         LDKChannelDetails this_ptr_conv;
28565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28566         this_ptr_conv.is_owned = false;
28567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28568         ChannelDetails_set_is_usable(&this_ptr_conv, val);
28569 }
28570
28571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
28572         LDKChannelDetails this_ptr_conv;
28573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28574         this_ptr_conv.is_owned = false;
28575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28576         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
28577         return ret_conv;
28578 }
28579
28580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28581         LDKChannelDetails this_ptr_conv;
28582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28583         this_ptr_conv.is_owned = false;
28584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28585         ChannelDetails_set_is_public(&this_ptr_conv, val);
28586 }
28587
28588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
28589         LDKThirtyTwoBytes channel_id_arg_ref;
28590         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28591         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28592         LDKChannelCounterparty counterparty_arg_conv;
28593         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
28594         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
28595         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
28596         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
28597         LDKOutPoint funding_txo_arg_conv;
28598         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
28599         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
28600         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
28601         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
28602         LDKChannelTypeFeatures channel_type_arg_conv;
28603         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
28604         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
28605         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
28606         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
28607         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
28608         CHECK_ACCESS(short_channel_id_arg_ptr);
28609         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
28610         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
28611         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
28612         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
28613         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
28614         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
28615         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
28616         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
28617         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
28618         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
28619         CHECK_ACCESS(confirmations_required_arg_ptr);
28620         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
28621         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
28622         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
28623         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
28624         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
28625         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
28626         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
28627         int64_t ret_ref = 0;
28628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28631         ret_ref = (uintptr_t)ret_var.inner;
28632         if (ret_var.is_owned) {
28633                 ret_ref |= 1;
28634         }
28635         return ret_ref;
28636 }
28637
28638 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
28639         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
28640 int64_t ret_ref = 0;
28641 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28642 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28643 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28644 ret_ref = (uintptr_t)ret_var.inner;
28645 if (ret_var.is_owned) {
28646         ret_ref |= 1;
28647 }
28648         return ret_ref;
28649 }
28650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28651         LDKChannelDetails arg_conv;
28652         arg_conv.inner = (void*)(arg & (~1));
28653         arg_conv.is_owned = false;
28654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28655         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
28656         return ret_conv;
28657 }
28658
28659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28660         LDKChannelDetails orig_conv;
28661         orig_conv.inner = (void*)(orig & (~1));
28662         orig_conv.is_owned = false;
28663         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28664         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
28665         int64_t ret_ref = 0;
28666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28669         ret_ref = (uintptr_t)ret_var.inner;
28670         if (ret_var.is_owned) {
28671                 ret_ref |= 1;
28672         }
28673         return ret_ref;
28674 }
28675
28676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
28677         LDKChannelDetails this_arg_conv;
28678         this_arg_conv.inner = (void*)(this_arg & (~1));
28679         this_arg_conv.is_owned = false;
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28681         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28682         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
28683         int64_t ret_ref = (uintptr_t)ret_copy;
28684         return ret_ref;
28685 }
28686
28687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28688         if ((this_ptr & 1) != 0) return;
28689         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28690         CHECK_ACCESS(this_ptr_ptr);
28691         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
28692         FREE((void*)this_ptr);
28693         PaymentSendFailure_free(this_ptr_conv);
28694 }
28695
28696 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
28697         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28698         *ret_copy = PaymentSendFailure_clone(arg);
28699 int64_t ret_ref = (uintptr_t)ret_copy;
28700         return ret_ref;
28701 }
28702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28703         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
28704         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
28705         return ret_conv;
28706 }
28707
28708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28709         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
28710         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28711         *ret_copy = PaymentSendFailure_clone(orig_conv);
28712         int64_t ret_ref = (uintptr_t)ret_copy;
28713         return ret_ref;
28714 }
28715
28716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
28717         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
28718         CHECK_ACCESS(a_ptr);
28719         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
28720         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
28721         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28722         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
28723         int64_t ret_ref = (uintptr_t)ret_copy;
28724         return ret_ref;
28725 }
28726
28727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
28728         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
28729         a_constr.datalen = (*env)->GetArrayLength(env, a);
28730         if (a_constr.datalen > 0)
28731                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28732         else
28733                 a_constr.data = NULL;
28734         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28735         for (size_t w = 0; w < a_constr.datalen; w++) {
28736                 int64_t a_conv_22 = a_vals[w];
28737                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
28738                 CHECK_ACCESS(a_conv_22_ptr);
28739                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
28740                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
28741                 a_constr.data[w] = a_conv_22_conv;
28742         }
28743         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28744         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28745         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
28746         int64_t ret_ref = (uintptr_t)ret_copy;
28747         return ret_ref;
28748 }
28749
28750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
28751         LDKCVec_APIErrorZ a_constr;
28752         a_constr.datalen = (*env)->GetArrayLength(env, a);
28753         if (a_constr.datalen > 0)
28754                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
28755         else
28756                 a_constr.data = NULL;
28757         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28758         for (size_t k = 0; k < a_constr.datalen; k++) {
28759                 int64_t a_conv_10 = a_vals[k];
28760                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
28761                 CHECK_ACCESS(a_conv_10_ptr);
28762                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
28763                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
28764                 a_constr.data[k] = a_conv_10_conv;
28765         }
28766         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28767         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28768         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
28769         int64_t ret_ref = (uintptr_t)ret_copy;
28770         return ret_ref;
28771 }
28772
28773 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) {
28774         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
28775         results_constr.datalen = (*env)->GetArrayLength(env, results);
28776         if (results_constr.datalen > 0)
28777                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28778         else
28779                 results_constr.data = NULL;
28780         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
28781         for (size_t w = 0; w < results_constr.datalen; w++) {
28782                 int64_t results_conv_22 = results_vals[w];
28783                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
28784                 CHECK_ACCESS(results_conv_22_ptr);
28785                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
28786                 results_constr.data[w] = results_conv_22_conv;
28787         }
28788         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
28789         LDKRouteParameters failed_paths_retry_conv;
28790         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
28791         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
28792         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
28793         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
28794         LDKThirtyTwoBytes payment_id_ref;
28795         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28796         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28797         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28798         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
28799         int64_t ret_ref = (uintptr_t)ret_copy;
28800         return ret_ref;
28801 }
28802
28803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28804         LDKPhantomRouteHints this_obj_conv;
28805         this_obj_conv.inner = (void*)(this_obj & (~1));
28806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28808         PhantomRouteHints_free(this_obj_conv);
28809 }
28810
28811 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28812         LDKPhantomRouteHints this_ptr_conv;
28813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28814         this_ptr_conv.is_owned = false;
28815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28816         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
28817         int64_tArray ret_arr = NULL;
28818         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28819         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28820         for (size_t q = 0; q < ret_var.datalen; q++) {
28821                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28822                 int64_t ret_conv_16_ref = 0;
28823                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28824                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28825                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28826                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28827                 if (ret_conv_16_var.is_owned) {
28828                         ret_conv_16_ref |= 1;
28829                 }
28830                 ret_arr_ptr[q] = ret_conv_16_ref;
28831         }
28832         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28833         FREE(ret_var.data);
28834         return ret_arr;
28835 }
28836
28837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28838         LDKPhantomRouteHints this_ptr_conv;
28839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28840         this_ptr_conv.is_owned = false;
28841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28842         LDKCVec_ChannelDetailsZ val_constr;
28843         val_constr.datalen = (*env)->GetArrayLength(env, val);
28844         if (val_constr.datalen > 0)
28845                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28846         else
28847                 val_constr.data = NULL;
28848         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28849         for (size_t q = 0; q < val_constr.datalen; q++) {
28850                 int64_t val_conv_16 = val_vals[q];
28851                 LDKChannelDetails val_conv_16_conv;
28852                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
28853                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
28854                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
28855                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
28856                 val_constr.data[q] = val_conv_16_conv;
28857         }
28858         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28859         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
28860 }
28861
28862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28863         LDKPhantomRouteHints this_ptr_conv;
28864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28865         this_ptr_conv.is_owned = false;
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28867         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
28868         return ret_conv;
28869 }
28870
28871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28872         LDKPhantomRouteHints this_ptr_conv;
28873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28874         this_ptr_conv.is_owned = false;
28875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28876         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
28877 }
28878
28879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28880         LDKPhantomRouteHints this_ptr_conv;
28881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28882         this_ptr_conv.is_owned = false;
28883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28884         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28885         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
28886         return ret_arr;
28887 }
28888
28889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28890         LDKPhantomRouteHints this_ptr_conv;
28891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28892         this_ptr_conv.is_owned = false;
28893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28894         LDKPublicKey val_ref;
28895         CHECK((*env)->GetArrayLength(env, val) == 33);
28896         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28897         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
28898 }
28899
28900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
28901         LDKCVec_ChannelDetailsZ channels_arg_constr;
28902         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28903         if (channels_arg_constr.datalen > 0)
28904                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28905         else
28906                 channels_arg_constr.data = NULL;
28907         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28908         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
28909                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
28910                 LDKChannelDetails channels_arg_conv_16_conv;
28911                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
28912                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
28913                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
28914                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
28915                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
28916         }
28917         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28918         LDKPublicKey real_node_pubkey_arg_ref;
28919         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
28920         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
28921         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
28922         int64_t ret_ref = 0;
28923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28926         ret_ref = (uintptr_t)ret_var.inner;
28927         if (ret_var.is_owned) {
28928                 ret_ref |= 1;
28929         }
28930         return ret_ref;
28931 }
28932
28933 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
28934         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
28935 int64_t ret_ref = 0;
28936 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28937 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28938 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28939 ret_ref = (uintptr_t)ret_var.inner;
28940 if (ret_var.is_owned) {
28941         ret_ref |= 1;
28942 }
28943         return ret_ref;
28944 }
28945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28946         LDKPhantomRouteHints arg_conv;
28947         arg_conv.inner = (void*)(arg & (~1));
28948         arg_conv.is_owned = false;
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28950         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
28951         return ret_conv;
28952 }
28953
28954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28955         LDKPhantomRouteHints orig_conv;
28956         orig_conv.inner = (void*)(orig & (~1));
28957         orig_conv.is_owned = false;
28958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28959         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
28960         int64_t ret_ref = 0;
28961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28964         ret_ref = (uintptr_t)ret_var.inner;
28965         if (ret_var.is_owned) {
28966                 ret_ref |= 1;
28967         }
28968         return ret_ref;
28969 }
28970
28971 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) {
28972         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
28973         CHECK_ACCESS(fee_est_ptr);
28974         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
28975         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
28976                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28977                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
28978         }
28979         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28980         CHECK_ACCESS(chain_monitor_ptr);
28981         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28982         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28983                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28984                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28985         }
28986         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28987         CHECK_ACCESS(tx_broadcaster_ptr);
28988         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28989         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28990                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28991                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28992         }
28993         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28994         CHECK_ACCESS(logger_ptr);
28995         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28996         if (logger_conv.free == LDKLogger_JCalls_free) {
28997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28998                 LDKLogger_JCalls_cloned(&logger_conv);
28999         }
29000         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29001         CHECK_ACCESS(keys_manager_ptr);
29002         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29003         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29004                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29005                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29006         }
29007         LDKUserConfig config_conv;
29008         config_conv.inner = (void*)(config & (~1));
29009         config_conv.is_owned = (config & 1) || (config == 0);
29010         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
29011         config_conv = UserConfig_clone(&config_conv);
29012         LDKChainParameters params_conv;
29013         params_conv.inner = (void*)(params & (~1));
29014         params_conv.is_owned = (params & 1) || (params == 0);
29015         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
29016         params_conv = ChainParameters_clone(&params_conv);
29017         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
29018         int64_t ret_ref = 0;
29019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29022         ret_ref = (uintptr_t)ret_var.inner;
29023         if (ret_var.is_owned) {
29024                 ret_ref |= 1;
29025         }
29026         return ret_ref;
29027 }
29028
29029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
29030         LDKChannelManager this_arg_conv;
29031         this_arg_conv.inner = (void*)(this_arg & (~1));
29032         this_arg_conv.is_owned = false;
29033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29034         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
29035         int64_t ret_ref = 0;
29036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29039         ret_ref = (uintptr_t)ret_var.inner;
29040         if (ret_var.is_owned) {
29041                 ret_ref |= 1;
29042         }
29043         return ret_ref;
29044 }
29045
29046 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) {
29047         LDKChannelManager this_arg_conv;
29048         this_arg_conv.inner = (void*)(this_arg & (~1));
29049         this_arg_conv.is_owned = false;
29050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29051         LDKPublicKey their_network_key_ref;
29052         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
29053         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
29054         LDKUserConfig override_config_conv;
29055         override_config_conv.inner = (void*)(override_config & (~1));
29056         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
29057         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
29058         override_config_conv = UserConfig_clone(&override_config_conv);
29059         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
29060         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
29061         return (int64_t)ret_conv;
29062 }
29063
29064 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29065         LDKChannelManager this_arg_conv;
29066         this_arg_conv.inner = (void*)(this_arg & (~1));
29067         this_arg_conv.is_owned = false;
29068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29069         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
29070         int64_tArray ret_arr = NULL;
29071         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29072         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29073         for (size_t q = 0; q < ret_var.datalen; q++) {
29074                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29075                 int64_t ret_conv_16_ref = 0;
29076                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29077                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29078                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29079                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29080                 if (ret_conv_16_var.is_owned) {
29081                         ret_conv_16_ref |= 1;
29082                 }
29083                 ret_arr_ptr[q] = ret_conv_16_ref;
29084         }
29085         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29086         FREE(ret_var.data);
29087         return ret_arr;
29088 }
29089
29090 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29091         LDKChannelManager this_arg_conv;
29092         this_arg_conv.inner = (void*)(this_arg & (~1));
29093         this_arg_conv.is_owned = false;
29094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29095         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
29096         int64_tArray ret_arr = NULL;
29097         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29098         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29099         for (size_t q = 0; q < ret_var.datalen; q++) {
29100                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29101                 int64_t ret_conv_16_ref = 0;
29102                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29103                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29104                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29105                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29106                 if (ret_conv_16_var.is_owned) {
29107                         ret_conv_16_ref |= 1;
29108                 }
29109                 ret_arr_ptr[q] = ret_conv_16_ref;
29110         }
29111         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29112         FREE(ret_var.data);
29113         return ret_arr;
29114 }
29115
29116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
29117         LDKChannelManager this_arg_conv;
29118         this_arg_conv.inner = (void*)(this_arg & (~1));
29119         this_arg_conv.is_owned = false;
29120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29121         unsigned char channel_id_arr[32];
29122         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29123         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29124         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29125         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29126         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
29127         return (int64_t)ret_conv;
29128 }
29129
29130 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) {
29131         LDKChannelManager this_arg_conv;
29132         this_arg_conv.inner = (void*)(this_arg & (~1));
29133         this_arg_conv.is_owned = false;
29134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29135         unsigned char channel_id_arr[32];
29136         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29137         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29138         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29139         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29140         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
29141         return (int64_t)ret_conv;
29142 }
29143
29144 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) {
29145         LDKChannelManager this_arg_conv;
29146         this_arg_conv.inner = (void*)(this_arg & (~1));
29147         this_arg_conv.is_owned = false;
29148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29149         unsigned char channel_id_arr[32];
29150         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29151         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29152         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29153         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29154         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
29155         return (int64_t)ret_conv;
29156 }
29157
29158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29159         LDKChannelManager this_arg_conv;
29160         this_arg_conv.inner = (void*)(this_arg & (~1));
29161         this_arg_conv.is_owned = false;
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29163         ChannelManager_force_close_all_channels(&this_arg_conv);
29164 }
29165
29166 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) {
29167         LDKChannelManager this_arg_conv;
29168         this_arg_conv.inner = (void*)(this_arg & (~1));
29169         this_arg_conv.is_owned = false;
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29171         LDKRoute route_conv;
29172         route_conv.inner = (void*)(route & (~1));
29173         route_conv.is_owned = false;
29174         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29175         LDKThirtyTwoBytes payment_hash_ref;
29176         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29177         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29178         LDKThirtyTwoBytes payment_secret_ref;
29179         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29180         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29181         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
29182         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
29183         return (int64_t)ret_conv;
29184 }
29185
29186 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) {
29187         LDKChannelManager this_arg_conv;
29188         this_arg_conv.inner = (void*)(this_arg & (~1));
29189         this_arg_conv.is_owned = false;
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29191         LDKRoute route_conv;
29192         route_conv.inner = (void*)(route & (~1));
29193         route_conv.is_owned = false;
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29195         LDKThirtyTwoBytes payment_id_ref;
29196         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29197         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29198         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
29199         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
29200         return (int64_t)ret_conv;
29201 }
29202
29203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
29204         LDKChannelManager this_arg_conv;
29205         this_arg_conv.inner = (void*)(this_arg & (~1));
29206         this_arg_conv.is_owned = false;
29207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29208         LDKThirtyTwoBytes payment_id_ref;
29209         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29210         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29211         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
29212 }
29213
29214 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) {
29215         LDKChannelManager this_arg_conv;
29216         this_arg_conv.inner = (void*)(this_arg & (~1));
29217         this_arg_conv.is_owned = false;
29218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29219         LDKRoute route_conv;
29220         route_conv.inner = (void*)(route & (~1));
29221         route_conv.is_owned = false;
29222         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29223         LDKThirtyTwoBytes payment_preimage_ref;
29224         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29225         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29226         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
29227         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
29228         return (int64_t)ret_conv;
29229 }
29230
29231 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) {
29232         LDKChannelManager this_arg_conv;
29233         this_arg_conv.inner = (void*)(this_arg & (~1));
29234         this_arg_conv.is_owned = false;
29235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29236         unsigned char temporary_channel_id_arr[32];
29237         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29238         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29239         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29240         LDKTransaction funding_transaction_ref;
29241         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
29242         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
29243         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
29244         funding_transaction_ref.data_is_owned = true;
29245         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29246         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
29247         return (int64_t)ret_conv;
29248 }
29249
29250 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) {
29251         LDKChannelManager this_arg_conv;
29252         this_arg_conv.inner = (void*)(this_arg & (~1));
29253         this_arg_conv.is_owned = false;
29254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29255         LDKThreeBytes rgb_ref;
29256         CHECK((*env)->GetArrayLength(env, rgb) == 3);
29257         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
29258         LDKThirtyTwoBytes alias_ref;
29259         CHECK((*env)->GetArrayLength(env, alias) == 32);
29260         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
29261         LDKCVec_NetAddressZ addresses_constr;
29262         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
29263         if (addresses_constr.datalen > 0)
29264                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29265         else
29266                 addresses_constr.data = NULL;
29267         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
29268         for (size_t m = 0; m < addresses_constr.datalen; m++) {
29269                 int64_t addresses_conv_12 = addresses_vals[m];
29270                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
29271                 CHECK_ACCESS(addresses_conv_12_ptr);
29272                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
29273                 addresses_constr.data[m] = addresses_conv_12_conv;
29274         }
29275         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
29276         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
29277 }
29278
29279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
29280         LDKChannelManager this_arg_conv;
29281         this_arg_conv.inner = (void*)(this_arg & (~1));
29282         this_arg_conv.is_owned = false;
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29284         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
29285 }
29286
29287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
29288         LDKChannelManager this_arg_conv;
29289         this_arg_conv.inner = (void*)(this_arg & (~1));
29290         this_arg_conv.is_owned = false;
29291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29292         ChannelManager_timer_tick_occurred(&this_arg_conv);
29293 }
29294
29295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
29296         LDKChannelManager this_arg_conv;
29297         this_arg_conv.inner = (void*)(this_arg & (~1));
29298         this_arg_conv.is_owned = false;
29299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29300         unsigned char payment_hash_arr[32];
29301         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29302         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
29303         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
29304         jboolean ret_conv = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
29305         return ret_conv;
29306 }
29307
29308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
29309         LDKChannelManager this_arg_conv;
29310         this_arg_conv.inner = (void*)(this_arg & (~1));
29311         this_arg_conv.is_owned = false;
29312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29313         LDKThirtyTwoBytes payment_preimage_ref;
29314         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29315         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29316         jboolean ret_conv = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
29317         return ret_conv;
29318 }
29319
29320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29321         LDKChannelManager this_arg_conv;
29322         this_arg_conv.inner = (void*)(this_arg & (~1));
29323         this_arg_conv.is_owned = false;
29324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29325         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
29327         return ret_arr;
29328 }
29329
29330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int64_t user_channel_id) {
29331         LDKChannelManager this_arg_conv;
29332         this_arg_conv.inner = (void*)(this_arg & (~1));
29333         this_arg_conv.is_owned = false;
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29335         unsigned char temporary_channel_id_arr[32];
29336         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29337         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29338         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29339         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29340         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
29341         return (int64_t)ret_conv;
29342 }
29343
29344 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) {
29345         LDKChannelManager this_arg_conv;
29346         this_arg_conv.inner = (void*)(this_arg & (~1));
29347         this_arg_conv.is_owned = false;
29348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29349         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29350         CHECK_ACCESS(min_value_msat_ptr);
29351         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29352         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29353         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
29354         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29355         return (int64_t)ret_conv;
29356 }
29357
29358 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) {
29359         LDKChannelManager this_arg_conv;
29360         this_arg_conv.inner = (void*)(this_arg & (~1));
29361         this_arg_conv.is_owned = false;
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29363         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29364         CHECK_ACCESS(min_value_msat_ptr);
29365         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29366         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29367         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
29368         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29369         return (int64_t)ret_conv;
29370 }
29371
29372 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) {
29373         LDKChannelManager this_arg_conv;
29374         this_arg_conv.inner = (void*)(this_arg & (~1));
29375         this_arg_conv.is_owned = false;
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29377         LDKThirtyTwoBytes payment_hash_ref;
29378         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29379         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29380         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29381         CHECK_ACCESS(min_value_msat_ptr);
29382         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29383         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29384         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
29385         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29386         return (int64_t)ret_conv;
29387 }
29388
29389 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) {
29390         LDKChannelManager this_arg_conv;
29391         this_arg_conv.inner = (void*)(this_arg & (~1));
29392         this_arg_conv.is_owned = false;
29393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29394         LDKThirtyTwoBytes payment_hash_ref;
29395         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29396         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29397         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29398         CHECK_ACCESS(min_value_msat_ptr);
29399         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29400         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29401         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
29402         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29403         return (int64_t)ret_conv;
29404 }
29405
29406 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) {
29407         LDKChannelManager this_arg_conv;
29408         this_arg_conv.inner = (void*)(this_arg & (~1));
29409         this_arg_conv.is_owned = false;
29410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29411         LDKThirtyTwoBytes payment_hash_ref;
29412         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29413         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29414         LDKThirtyTwoBytes payment_secret_ref;
29415         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29416         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29417         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
29418         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
29419         return (int64_t)ret_conv;
29420 }
29421
29422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29423         LDKChannelManager this_arg_conv;
29424         this_arg_conv.inner = (void*)(this_arg & (~1));
29425         this_arg_conv.is_owned = false;
29426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29427         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
29428         return ret_conv;
29429 }
29430
29431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
29432         LDKChannelManager this_arg_conv;
29433         this_arg_conv.inner = (void*)(this_arg & (~1));
29434         this_arg_conv.is_owned = false;
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29436         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
29437         int64_t ret_ref = 0;
29438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29441         ret_ref = (uintptr_t)ret_var.inner;
29442         if (ret_var.is_owned) {
29443                 ret_ref |= 1;
29444         }
29445         return ret_ref;
29446 }
29447
29448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29449         LDKChannelManager this_arg_conv;
29450         this_arg_conv.inner = (void*)(this_arg & (~1));
29451         this_arg_conv.is_owned = false;
29452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29453         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
29454         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
29455         return (int64_t)ret_ret;
29456 }
29457
29458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29459         LDKChannelManager this_arg_conv;
29460         this_arg_conv.inner = (void*)(this_arg & (~1));
29461         this_arg_conv.is_owned = false;
29462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29463         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29464         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
29465         return (int64_t)ret_ret;
29466 }
29467
29468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29469         LDKChannelManager this_arg_conv;
29470         this_arg_conv.inner = (void*)(this_arg & (~1));
29471         this_arg_conv.is_owned = false;
29472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29473         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29474         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
29475         return (int64_t)ret_ret;
29476 }
29477
29478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29479         LDKChannelManager this_arg_conv;
29480         this_arg_conv.inner = (void*)(this_arg & (~1));
29481         this_arg_conv.is_owned = false;
29482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29483         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29484         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
29485         return (int64_t)ret_ret;
29486 }
29487
29488 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) {
29489         LDKChannelManager this_arg_conv;
29490         this_arg_conv.inner = (void*)(this_arg & (~1));
29491         this_arg_conv.is_owned = false;
29492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29493         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
29494         return ret_conv;
29495 }
29496
29497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
29498         LDKChannelManager this_arg_conv;
29499         this_arg_conv.inner = (void*)(this_arg & (~1));
29500         this_arg_conv.is_owned = false;
29501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29502         ChannelManager_await_persistable_update(&this_arg_conv);
29503 }
29504
29505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
29506         LDKChannelManager this_arg_conv;
29507         this_arg_conv.inner = (void*)(this_arg & (~1));
29508         this_arg_conv.is_owned = false;
29509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29510         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
29511         int64_t ret_ref = 0;
29512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29515         ret_ref = (uintptr_t)ret_var.inner;
29516         if (ret_var.is_owned) {
29517                 ret_ref |= 1;
29518         }
29519         return ret_ref;
29520 }
29521
29522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29523         LDKChannelManager this_arg_conv;
29524         this_arg_conv.inner = (void*)(this_arg & (~1));
29525         this_arg_conv.is_owned = false;
29526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29527         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
29528         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
29529         return (int64_t)ret_ret;
29530 }
29531
29532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29533         LDKCounterpartyForwardingInfo obj_conv;
29534         obj_conv.inner = (void*)(obj & (~1));
29535         obj_conv.is_owned = false;
29536         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29537         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
29538         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29539         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29540         CVec_u8Z_free(ret_var);
29541         return ret_arr;
29542 }
29543
29544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29545         LDKu8slice ser_ref;
29546         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29547         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29548         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
29549         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
29550         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29551         return (int64_t)ret_conv;
29552 }
29553
29554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
29555         LDKChannelCounterparty obj_conv;
29556         obj_conv.inner = (void*)(obj & (~1));
29557         obj_conv.is_owned = false;
29558         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29559         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
29560         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29561         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29562         CVec_u8Z_free(ret_var);
29563         return ret_arr;
29564 }
29565
29566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29567         LDKu8slice ser_ref;
29568         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29569         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29570         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
29571         *ret_conv = ChannelCounterparty_read(ser_ref);
29572         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29573         return (int64_t)ret_conv;
29574 }
29575
29576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
29577         LDKChannelDetails obj_conv;
29578         obj_conv.inner = (void*)(obj & (~1));
29579         obj_conv.is_owned = false;
29580         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29581         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
29582         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29583         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29584         CVec_u8Z_free(ret_var);
29585         return ret_arr;
29586 }
29587
29588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29589         LDKu8slice ser_ref;
29590         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29591         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29592         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
29593         *ret_conv = ChannelDetails_read(ser_ref);
29594         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29595         return (int64_t)ret_conv;
29596 }
29597
29598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
29599         LDKPhantomRouteHints obj_conv;
29600         obj_conv.inner = (void*)(obj & (~1));
29601         obj_conv.is_owned = false;
29602         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29603         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
29604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29606         CVec_u8Z_free(ret_var);
29607         return ret_arr;
29608 }
29609
29610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29611         LDKu8slice ser_ref;
29612         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29613         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29614         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
29615         *ret_conv = PhantomRouteHints_read(ser_ref);
29616         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29617         return (int64_t)ret_conv;
29618 }
29619
29620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
29621         LDKChannelManager obj_conv;
29622         obj_conv.inner = (void*)(obj & (~1));
29623         obj_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29625         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
29626         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29627         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29628         CVec_u8Z_free(ret_var);
29629         return ret_arr;
29630 }
29631
29632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29633         LDKChannelManagerReadArgs this_obj_conv;
29634         this_obj_conv.inner = (void*)(this_obj & (~1));
29635         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29637         ChannelManagerReadArgs_free(this_obj_conv);
29638 }
29639
29640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
29641         LDKChannelManagerReadArgs this_ptr_conv;
29642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29643         this_ptr_conv.is_owned = false;
29644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29645         // WARNING: This object doesn't live past this scope, needs clone!
29646         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
29647         return ret_ret;
29648 }
29649
29650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29651         LDKChannelManagerReadArgs this_ptr_conv;
29652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29653         this_ptr_conv.is_owned = false;
29654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29655         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29656         CHECK_ACCESS(val_ptr);
29657         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
29658         if (val_conv.free == LDKKeysInterface_JCalls_free) {
29659                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29660                 LDKKeysInterface_JCalls_cloned(&val_conv);
29661         }
29662         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
29663 }
29664
29665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
29666         LDKChannelManagerReadArgs this_ptr_conv;
29667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29668         this_ptr_conv.is_owned = false;
29669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29670         // WARNING: This object doesn't live past this scope, needs clone!
29671         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
29672         return ret_ret;
29673 }
29674
29675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29676         LDKChannelManagerReadArgs this_ptr_conv;
29677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29678         this_ptr_conv.is_owned = false;
29679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29680         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29681         CHECK_ACCESS(val_ptr);
29682         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
29683         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
29684                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29685                 LDKFeeEstimator_JCalls_cloned(&val_conv);
29686         }
29687         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
29688 }
29689
29690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
29691         LDKChannelManagerReadArgs this_ptr_conv;
29692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29693         this_ptr_conv.is_owned = false;
29694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29695         // WARNING: This object doesn't live past this scope, needs clone!
29696         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
29697         return ret_ret;
29698 }
29699
29700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29701         LDKChannelManagerReadArgs this_ptr_conv;
29702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29703         this_ptr_conv.is_owned = false;
29704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29705         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29706         CHECK_ACCESS(val_ptr);
29707         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
29708         if (val_conv.free == LDKWatch_JCalls_free) {
29709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29710                 LDKWatch_JCalls_cloned(&val_conv);
29711         }
29712         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
29713 }
29714
29715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
29716         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
29721         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
29722         return ret_ret;
29723 }
29724
29725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29726         LDKChannelManagerReadArgs 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         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29731         CHECK_ACCESS(val_ptr);
29732         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
29733         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
29734                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29735                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
29736         }
29737         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
29738 }
29739
29740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
29741         LDKChannelManagerReadArgs this_ptr_conv;
29742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29743         this_ptr_conv.is_owned = false;
29744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29745         // WARNING: This object doesn't live past this scope, needs clone!
29746         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
29747         return ret_ret;
29748 }
29749
29750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29751         LDKChannelManagerReadArgs this_ptr_conv;
29752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29753         this_ptr_conv.is_owned = false;
29754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29755         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29756         CHECK_ACCESS(val_ptr);
29757         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
29758         if (val_conv.free == LDKLogger_JCalls_free) {
29759                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29760                 LDKLogger_JCalls_cloned(&val_conv);
29761         }
29762         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
29763 }
29764
29765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29766         LDKChannelManagerReadArgs this_ptr_conv;
29767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29768         this_ptr_conv.is_owned = false;
29769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29770         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
29771         int64_t ret_ref = 0;
29772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29775         ret_ref = (uintptr_t)ret_var.inner;
29776         if (ret_var.is_owned) {
29777                 ret_ref |= 1;
29778         }
29779         return ret_ref;
29780 }
29781
29782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29783         LDKChannelManagerReadArgs this_ptr_conv;
29784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29785         this_ptr_conv.is_owned = false;
29786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29787         LDKUserConfig val_conv;
29788         val_conv.inner = (void*)(val & (~1));
29789         val_conv.is_owned = (val & 1) || (val == 0);
29790         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29791         val_conv = UserConfig_clone(&val_conv);
29792         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
29793 }
29794
29795 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) {
29796         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29797         CHECK_ACCESS(keys_manager_ptr);
29798         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29799         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29800                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29801                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29802         }
29803         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
29804         CHECK_ACCESS(fee_estimator_ptr);
29805         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29806         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29807                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29808                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29809         }
29810         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
29811         CHECK_ACCESS(chain_monitor_ptr);
29812         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29813         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29814                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29815                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29816         }
29817         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
29818         CHECK_ACCESS(tx_broadcaster_ptr);
29819         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29820         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29821                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29822                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29823         }
29824         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
29825         CHECK_ACCESS(logger_ptr);
29826         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29827         if (logger_conv.free == LDKLogger_JCalls_free) {
29828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29829                 LDKLogger_JCalls_cloned(&logger_conv);
29830         }
29831         LDKUserConfig default_config_conv;
29832         default_config_conv.inner = (void*)(default_config & (~1));
29833         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
29834         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
29835         default_config_conv = UserConfig_clone(&default_config_conv);
29836         LDKCVec_ChannelMonitorZ channel_monitors_constr;
29837         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
29838         if (channel_monitors_constr.datalen > 0)
29839                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
29840         else
29841                 channel_monitors_constr.data = NULL;
29842         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
29843         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
29844                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
29845                 LDKChannelMonitor channel_monitors_conv_16_conv;
29846                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
29847                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
29848                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
29849                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
29850         }
29851         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
29852         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);
29853         int64_t ret_ref = 0;
29854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29857         ret_ref = (uintptr_t)ret_var.inner;
29858         if (ret_var.is_owned) {
29859                 ret_ref |= 1;
29860         }
29861         return ret_ref;
29862 }
29863
29864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29865         LDKu8slice ser_ref;
29866         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29867         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29868         LDKChannelManagerReadArgs arg_conv;
29869         arg_conv.inner = (void*)(arg & (~1));
29870         arg_conv.is_owned = (arg & 1) || (arg == 0);
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29872         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
29873         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
29874         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
29875         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29876         return (int64_t)ret_conv;
29877 }
29878
29879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29880         LDKDecodeError this_obj_conv;
29881         this_obj_conv.inner = (void*)(this_obj & (~1));
29882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29884         DecodeError_free(this_obj_conv);
29885 }
29886
29887 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
29888         LDKDecodeError ret_var = DecodeError_clone(arg);
29889 int64_t ret_ref = 0;
29890 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29891 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29892 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29893 ret_ref = (uintptr_t)ret_var.inner;
29894 if (ret_var.is_owned) {
29895         ret_ref |= 1;
29896 }
29897         return ret_ref;
29898 }
29899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29900         LDKDecodeError arg_conv;
29901         arg_conv.inner = (void*)(arg & (~1));
29902         arg_conv.is_owned = false;
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29904         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
29905         return ret_conv;
29906 }
29907
29908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29909         LDKDecodeError orig_conv;
29910         orig_conv.inner = (void*)(orig & (~1));
29911         orig_conv.is_owned = false;
29912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29913         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
29914         int64_t ret_ref = 0;
29915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29918         ret_ref = (uintptr_t)ret_var.inner;
29919         if (ret_var.is_owned) {
29920                 ret_ref |= 1;
29921         }
29922         return ret_ref;
29923 }
29924
29925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29926         LDKInit this_obj_conv;
29927         this_obj_conv.inner = (void*)(this_obj & (~1));
29928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29930         Init_free(this_obj_conv);
29931 }
29932
29933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29934         LDKInit this_ptr_conv;
29935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29936         this_ptr_conv.is_owned = false;
29937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29938         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
29939         int64_t ret_ref = 0;
29940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29943         ret_ref = (uintptr_t)ret_var.inner;
29944         if (ret_var.is_owned) {
29945                 ret_ref |= 1;
29946         }
29947         return ret_ref;
29948 }
29949
29950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29951         LDKInit this_ptr_conv;
29952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29953         this_ptr_conv.is_owned = false;
29954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29955         LDKInitFeatures val_conv;
29956         val_conv.inner = (void*)(val & (~1));
29957         val_conv.is_owned = (val & 1) || (val == 0);
29958         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29959         val_conv = InitFeatures_clone(&val_conv);
29960         Init_set_features(&this_ptr_conv, val_conv);
29961 }
29962
29963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
29964         LDKInit this_ptr_conv;
29965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29966         this_ptr_conv.is_owned = false;
29967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29968         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
29969         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
29970         int64_t ret_ref = (uintptr_t)ret_copy;
29971         return ret_ref;
29972 }
29973
29974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29975         LDKInit this_ptr_conv;
29976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29977         this_ptr_conv.is_owned = false;
29978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29979         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29980         CHECK_ACCESS(val_ptr);
29981         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
29982         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
29983         Init_set_remote_network_address(&this_ptr_conv, val_conv);
29984 }
29985
29986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t remote_network_address_arg) {
29987         LDKInitFeatures features_arg_conv;
29988         features_arg_conv.inner = (void*)(features_arg & (~1));
29989         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29991         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29992         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
29993         CHECK_ACCESS(remote_network_address_arg_ptr);
29994         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
29995         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
29996         int64_t ret_ref = 0;
29997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30000         ret_ref = (uintptr_t)ret_var.inner;
30001         if (ret_var.is_owned) {
30002                 ret_ref |= 1;
30003         }
30004         return ret_ref;
30005 }
30006
30007 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
30008         LDKInit ret_var = Init_clone(arg);
30009 int64_t ret_ref = 0;
30010 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30011 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30012 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30013 ret_ref = (uintptr_t)ret_var.inner;
30014 if (ret_var.is_owned) {
30015         ret_ref |= 1;
30016 }
30017         return ret_ref;
30018 }
30019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30020         LDKInit arg_conv;
30021         arg_conv.inner = (void*)(arg & (~1));
30022         arg_conv.is_owned = false;
30023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30024         int64_t ret_conv = Init_clone_ptr(&arg_conv);
30025         return ret_conv;
30026 }
30027
30028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30029         LDKInit orig_conv;
30030         orig_conv.inner = (void*)(orig & (~1));
30031         orig_conv.is_owned = false;
30032         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30033         LDKInit ret_var = Init_clone(&orig_conv);
30034         int64_t ret_ref = 0;
30035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30038         ret_ref = (uintptr_t)ret_var.inner;
30039         if (ret_var.is_owned) {
30040                 ret_ref |= 1;
30041         }
30042         return ret_ref;
30043 }
30044
30045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30046         LDKErrorMessage this_obj_conv;
30047         this_obj_conv.inner = (void*)(this_obj & (~1));
30048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30050         ErrorMessage_free(this_obj_conv);
30051 }
30052
30053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30054         LDKErrorMessage this_ptr_conv;
30055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30056         this_ptr_conv.is_owned = false;
30057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30058         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30059         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
30060         return ret_arr;
30061 }
30062
30063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30064         LDKErrorMessage this_ptr_conv;
30065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30066         this_ptr_conv.is_owned = false;
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30068         LDKThirtyTwoBytes val_ref;
30069         CHECK((*env)->GetArrayLength(env, val) == 32);
30070         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30071         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
30072 }
30073
30074 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30075         LDKErrorMessage this_ptr_conv;
30076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30077         this_ptr_conv.is_owned = false;
30078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30079         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
30080         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30081         Str_free(ret_str);
30082         return ret_conv;
30083 }
30084
30085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30086         LDKErrorMessage this_ptr_conv;
30087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30088         this_ptr_conv.is_owned = false;
30089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30090         LDKStr val_conv = java_to_owned_str(env, val);
30091         ErrorMessage_set_data(&this_ptr_conv, val_conv);
30092 }
30093
30094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30095         LDKThirtyTwoBytes channel_id_arg_ref;
30096         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30097         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30098         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30099         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
30100         int64_t ret_ref = 0;
30101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30104         ret_ref = (uintptr_t)ret_var.inner;
30105         if (ret_var.is_owned) {
30106                 ret_ref |= 1;
30107         }
30108         return ret_ref;
30109 }
30110
30111 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
30112         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
30113 int64_t ret_ref = 0;
30114 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30115 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30116 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30117 ret_ref = (uintptr_t)ret_var.inner;
30118 if (ret_var.is_owned) {
30119         ret_ref |= 1;
30120 }
30121         return ret_ref;
30122 }
30123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30124         LDKErrorMessage arg_conv;
30125         arg_conv.inner = (void*)(arg & (~1));
30126         arg_conv.is_owned = false;
30127         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30128         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
30129         return ret_conv;
30130 }
30131
30132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30133         LDKErrorMessage orig_conv;
30134         orig_conv.inner = (void*)(orig & (~1));
30135         orig_conv.is_owned = false;
30136         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30137         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
30138         int64_t ret_ref = 0;
30139         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30140         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30142         ret_ref = (uintptr_t)ret_var.inner;
30143         if (ret_var.is_owned) {
30144                 ret_ref |= 1;
30145         }
30146         return ret_ref;
30147 }
30148
30149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30150         LDKWarningMessage this_obj_conv;
30151         this_obj_conv.inner = (void*)(this_obj & (~1));
30152         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30154         WarningMessage_free(this_obj_conv);
30155 }
30156
30157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30158         LDKWarningMessage this_ptr_conv;
30159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30160         this_ptr_conv.is_owned = false;
30161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30162         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
30164         return ret_arr;
30165 }
30166
30167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30168         LDKWarningMessage this_ptr_conv;
30169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30170         this_ptr_conv.is_owned = false;
30171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30172         LDKThirtyTwoBytes val_ref;
30173         CHECK((*env)->GetArrayLength(env, val) == 32);
30174         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30175         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
30176 }
30177
30178 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30179         LDKWarningMessage this_ptr_conv;
30180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30181         this_ptr_conv.is_owned = false;
30182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30183         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
30184         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30185         Str_free(ret_str);
30186         return ret_conv;
30187 }
30188
30189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30190         LDKWarningMessage this_ptr_conv;
30191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30192         this_ptr_conv.is_owned = false;
30193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30194         LDKStr val_conv = java_to_owned_str(env, val);
30195         WarningMessage_set_data(&this_ptr_conv, val_conv);
30196 }
30197
30198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30199         LDKThirtyTwoBytes channel_id_arg_ref;
30200         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30201         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30202         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30203         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
30204         int64_t ret_ref = 0;
30205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30208         ret_ref = (uintptr_t)ret_var.inner;
30209         if (ret_var.is_owned) {
30210                 ret_ref |= 1;
30211         }
30212         return ret_ref;
30213 }
30214
30215 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
30216         LDKWarningMessage ret_var = WarningMessage_clone(arg);
30217 int64_t ret_ref = 0;
30218 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30219 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30220 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30221 ret_ref = (uintptr_t)ret_var.inner;
30222 if (ret_var.is_owned) {
30223         ret_ref |= 1;
30224 }
30225         return ret_ref;
30226 }
30227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30228         LDKWarningMessage arg_conv;
30229         arg_conv.inner = (void*)(arg & (~1));
30230         arg_conv.is_owned = false;
30231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30232         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
30233         return ret_conv;
30234 }
30235
30236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30237         LDKWarningMessage orig_conv;
30238         orig_conv.inner = (void*)(orig & (~1));
30239         orig_conv.is_owned = false;
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30241         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
30242         int64_t ret_ref = 0;
30243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30246         ret_ref = (uintptr_t)ret_var.inner;
30247         if (ret_var.is_owned) {
30248                 ret_ref |= 1;
30249         }
30250         return ret_ref;
30251 }
30252
30253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30254         LDKPing this_obj_conv;
30255         this_obj_conv.inner = (void*)(this_obj & (~1));
30256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30258         Ping_free(this_obj_conv);
30259 }
30260
30261 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30262         LDKPing this_ptr_conv;
30263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30264         this_ptr_conv.is_owned = false;
30265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30266         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
30267         return ret_conv;
30268 }
30269
30270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30271         LDKPing this_ptr_conv;
30272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30273         this_ptr_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30275         Ping_set_ponglen(&this_ptr_conv, val);
30276 }
30277
30278 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30279         LDKPing this_ptr_conv;
30280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30281         this_ptr_conv.is_owned = false;
30282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30283         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
30284         return ret_conv;
30285 }
30286
30287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30288         LDKPing this_ptr_conv;
30289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30290         this_ptr_conv.is_owned = false;
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30292         Ping_set_byteslen(&this_ptr_conv, val);
30293 }
30294
30295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
30296         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
30297         int64_t ret_ref = 0;
30298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30301         ret_ref = (uintptr_t)ret_var.inner;
30302         if (ret_var.is_owned) {
30303                 ret_ref |= 1;
30304         }
30305         return ret_ref;
30306 }
30307
30308 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
30309         LDKPing ret_var = Ping_clone(arg);
30310 int64_t ret_ref = 0;
30311 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30312 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30313 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30314 ret_ref = (uintptr_t)ret_var.inner;
30315 if (ret_var.is_owned) {
30316         ret_ref |= 1;
30317 }
30318         return ret_ref;
30319 }
30320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30321         LDKPing arg_conv;
30322         arg_conv.inner = (void*)(arg & (~1));
30323         arg_conv.is_owned = false;
30324         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30325         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
30326         return ret_conv;
30327 }
30328
30329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30330         LDKPing orig_conv;
30331         orig_conv.inner = (void*)(orig & (~1));
30332         orig_conv.is_owned = false;
30333         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30334         LDKPing ret_var = Ping_clone(&orig_conv);
30335         int64_t ret_ref = 0;
30336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30339         ret_ref = (uintptr_t)ret_var.inner;
30340         if (ret_var.is_owned) {
30341                 ret_ref |= 1;
30342         }
30343         return ret_ref;
30344 }
30345
30346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30347         LDKPong this_obj_conv;
30348         this_obj_conv.inner = (void*)(this_obj & (~1));
30349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30351         Pong_free(this_obj_conv);
30352 }
30353
30354 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30355         LDKPong this_ptr_conv;
30356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30357         this_ptr_conv.is_owned = false;
30358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30359         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
30360         return ret_conv;
30361 }
30362
30363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30364         LDKPong this_ptr_conv;
30365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30366         this_ptr_conv.is_owned = false;
30367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30368         Pong_set_byteslen(&this_ptr_conv, val);
30369 }
30370
30371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
30372         LDKPong ret_var = Pong_new(byteslen_arg);
30373         int64_t ret_ref = 0;
30374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30377         ret_ref = (uintptr_t)ret_var.inner;
30378         if (ret_var.is_owned) {
30379                 ret_ref |= 1;
30380         }
30381         return ret_ref;
30382 }
30383
30384 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
30385         LDKPong ret_var = Pong_clone(arg);
30386 int64_t ret_ref = 0;
30387 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30388 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30389 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30390 ret_ref = (uintptr_t)ret_var.inner;
30391 if (ret_var.is_owned) {
30392         ret_ref |= 1;
30393 }
30394         return ret_ref;
30395 }
30396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30397         LDKPong arg_conv;
30398         arg_conv.inner = (void*)(arg & (~1));
30399         arg_conv.is_owned = false;
30400         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30401         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
30402         return ret_conv;
30403 }
30404
30405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30406         LDKPong orig_conv;
30407         orig_conv.inner = (void*)(orig & (~1));
30408         orig_conv.is_owned = false;
30409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30410         LDKPong ret_var = Pong_clone(&orig_conv);
30411         int64_t ret_ref = 0;
30412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30415         ret_ref = (uintptr_t)ret_var.inner;
30416         if (ret_var.is_owned) {
30417                 ret_ref |= 1;
30418         }
30419         return ret_ref;
30420 }
30421
30422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30423         LDKOpenChannel this_obj_conv;
30424         this_obj_conv.inner = (void*)(this_obj & (~1));
30425         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30427         OpenChannel_free(this_obj_conv);
30428 }
30429
30430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30431         LDKOpenChannel this_ptr_conv;
30432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30433         this_ptr_conv.is_owned = false;
30434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30435         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30436         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
30437         return ret_arr;
30438 }
30439
30440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30441         LDKOpenChannel this_ptr_conv;
30442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30443         this_ptr_conv.is_owned = false;
30444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30445         LDKThirtyTwoBytes val_ref;
30446         CHECK((*env)->GetArrayLength(env, val) == 32);
30447         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30448         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
30449 }
30450
30451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30452         LDKOpenChannel this_ptr_conv;
30453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30454         this_ptr_conv.is_owned = false;
30455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30456         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30457         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
30458         return ret_arr;
30459 }
30460
30461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30462         LDKOpenChannel this_ptr_conv;
30463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30464         this_ptr_conv.is_owned = false;
30465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30466         LDKThirtyTwoBytes val_ref;
30467         CHECK((*env)->GetArrayLength(env, val) == 32);
30468         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30469         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30470 }
30471
30472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30473         LDKOpenChannel this_ptr_conv;
30474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30475         this_ptr_conv.is_owned = false;
30476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30477         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
30478         return ret_conv;
30479 }
30480
30481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30482         LDKOpenChannel this_ptr_conv;
30483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30484         this_ptr_conv.is_owned = false;
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30486         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
30487 }
30488
30489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30490         LDKOpenChannel this_ptr_conv;
30491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30492         this_ptr_conv.is_owned = false;
30493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30494         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
30495         return ret_conv;
30496 }
30497
30498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30499         LDKOpenChannel this_ptr_conv;
30500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30501         this_ptr_conv.is_owned = false;
30502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30503         OpenChannel_set_push_msat(&this_ptr_conv, val);
30504 }
30505
30506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30507         LDKOpenChannel this_ptr_conv;
30508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30509         this_ptr_conv.is_owned = false;
30510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30511         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
30512         return ret_conv;
30513 }
30514
30515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30516         LDKOpenChannel this_ptr_conv;
30517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30518         this_ptr_conv.is_owned = false;
30519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30520         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30521 }
30522
30523 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) {
30524         LDKOpenChannel this_ptr_conv;
30525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30526         this_ptr_conv.is_owned = false;
30527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30528         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30529         return ret_conv;
30530 }
30531
30532 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) {
30533         LDKOpenChannel this_ptr_conv;
30534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30535         this_ptr_conv.is_owned = false;
30536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30537         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30538 }
30539
30540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30541         LDKOpenChannel this_ptr_conv;
30542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30543         this_ptr_conv.is_owned = false;
30544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30545         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30546         return ret_conv;
30547 }
30548
30549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30550         LDKOpenChannel this_ptr_conv;
30551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30552         this_ptr_conv.is_owned = false;
30553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30554         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30555 }
30556
30557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30558         LDKOpenChannel this_ptr_conv;
30559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30560         this_ptr_conv.is_owned = false;
30561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30562         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
30563         return ret_conv;
30564 }
30565
30566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30567         LDKOpenChannel this_ptr_conv;
30568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30569         this_ptr_conv.is_owned = false;
30570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30571         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30572 }
30573
30574 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
30575         LDKOpenChannel this_ptr_conv;
30576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30577         this_ptr_conv.is_owned = false;
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30579         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
30580         return ret_conv;
30581 }
30582
30583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30584         LDKOpenChannel this_ptr_conv;
30585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30586         this_ptr_conv.is_owned = false;
30587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30588         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
30589 }
30590
30591 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30592         LDKOpenChannel this_ptr_conv;
30593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30594         this_ptr_conv.is_owned = false;
30595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30596         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
30597         return ret_conv;
30598 }
30599
30600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30601         LDKOpenChannel this_ptr_conv;
30602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30603         this_ptr_conv.is_owned = false;
30604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30605         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
30606 }
30607
30608 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30609         LDKOpenChannel this_ptr_conv;
30610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30611         this_ptr_conv.is_owned = false;
30612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30613         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
30614         return ret_conv;
30615 }
30616
30617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30618         LDKOpenChannel 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         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30623 }
30624
30625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30626         LDKOpenChannel this_ptr_conv;
30627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30628         this_ptr_conv.is_owned = false;
30629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30630         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30631         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30632         return ret_arr;
30633 }
30634
30635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30636         LDKOpenChannel this_ptr_conv;
30637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30638         this_ptr_conv.is_owned = false;
30639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30640         LDKPublicKey val_ref;
30641         CHECK((*env)->GetArrayLength(env, val) == 33);
30642         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30643         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30644 }
30645
30646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30647         LDKOpenChannel this_ptr_conv;
30648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30649         this_ptr_conv.is_owned = false;
30650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30651         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30652         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30653         return ret_arr;
30654 }
30655
30656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30657         LDKOpenChannel this_ptr_conv;
30658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30659         this_ptr_conv.is_owned = false;
30660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30661         LDKPublicKey val_ref;
30662         CHECK((*env)->GetArrayLength(env, val) == 33);
30663         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30664         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30665 }
30666
30667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30668         LDKOpenChannel this_ptr_conv;
30669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30670         this_ptr_conv.is_owned = false;
30671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30672         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
30674         return ret_arr;
30675 }
30676
30677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30678         LDKOpenChannel this_ptr_conv;
30679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30680         this_ptr_conv.is_owned = false;
30681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30682         LDKPublicKey val_ref;
30683         CHECK((*env)->GetArrayLength(env, val) == 33);
30684         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30685         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
30686 }
30687
30688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30689         LDKOpenChannel this_ptr_conv;
30690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30691         this_ptr_conv.is_owned = false;
30692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30693         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30694         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30695         return ret_arr;
30696 }
30697
30698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30699         LDKOpenChannel this_ptr_conv;
30700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30701         this_ptr_conv.is_owned = false;
30702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30703         LDKPublicKey val_ref;
30704         CHECK((*env)->GetArrayLength(env, val) == 33);
30705         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30706         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30707 }
30708
30709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30710         LDKOpenChannel this_ptr_conv;
30711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30712         this_ptr_conv.is_owned = false;
30713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30714         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30716         return ret_arr;
30717 }
30718
30719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30720         LDKOpenChannel this_ptr_conv;
30721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30722         this_ptr_conv.is_owned = false;
30723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30724         LDKPublicKey val_ref;
30725         CHECK((*env)->GetArrayLength(env, val) == 33);
30726         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30727         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30728 }
30729
30730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30731         LDKOpenChannel this_ptr_conv;
30732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30733         this_ptr_conv.is_owned = false;
30734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30735         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30737         return ret_arr;
30738 }
30739
30740 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) {
30741         LDKOpenChannel this_ptr_conv;
30742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30743         this_ptr_conv.is_owned = false;
30744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30745         LDKPublicKey val_ref;
30746         CHECK((*env)->GetArrayLength(env, val) == 33);
30747         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30748         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30749 }
30750
30751 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
30752         LDKOpenChannel this_ptr_conv;
30753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30754         this_ptr_conv.is_owned = false;
30755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30756         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
30757         return ret_conv;
30758 }
30759
30760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
30761         LDKOpenChannel this_ptr_conv;
30762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30763         this_ptr_conv.is_owned = false;
30764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30765         OpenChannel_set_channel_flags(&this_ptr_conv, val);
30766 }
30767
30768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30769         LDKOpenChannel this_ptr_conv;
30770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30771         this_ptr_conv.is_owned = false;
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30773         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
30774         int64_t ret_ref = 0;
30775         if ((uintptr_t)ret_var.inner > 4096) {
30776                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30777                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30779                 ret_ref = (uintptr_t)ret_var.inner;
30780                 if (ret_var.is_owned) {
30781                         ret_ref |= 1;
30782                 }
30783         }
30784         return ret_ref;
30785 }
30786
30787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30788         LDKOpenChannel this_ptr_conv;
30789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30790         this_ptr_conv.is_owned = false;
30791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30792         LDKChannelTypeFeatures val_conv;
30793         val_conv.inner = (void*)(val & (~1));
30794         val_conv.is_owned = (val & 1) || (val == 0);
30795         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30796         val_conv = ChannelTypeFeatures_clone(&val_conv);
30797         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
30798 }
30799
30800 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
30801         LDKOpenChannel ret_var = OpenChannel_clone(arg);
30802 int64_t ret_ref = 0;
30803 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30804 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30805 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30806 ret_ref = (uintptr_t)ret_var.inner;
30807 if (ret_var.is_owned) {
30808         ret_ref |= 1;
30809 }
30810         return ret_ref;
30811 }
30812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30813         LDKOpenChannel arg_conv;
30814         arg_conv.inner = (void*)(arg & (~1));
30815         arg_conv.is_owned = false;
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30817         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
30818         return ret_conv;
30819 }
30820
30821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30822         LDKOpenChannel orig_conv;
30823         orig_conv.inner = (void*)(orig & (~1));
30824         orig_conv.is_owned = false;
30825         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30826         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
30827         int64_t ret_ref = 0;
30828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30831         ret_ref = (uintptr_t)ret_var.inner;
30832         if (ret_var.is_owned) {
30833                 ret_ref |= 1;
30834         }
30835         return ret_ref;
30836 }
30837
30838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30839         LDKAcceptChannel this_obj_conv;
30840         this_obj_conv.inner = (void*)(this_obj & (~1));
30841         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30843         AcceptChannel_free(this_obj_conv);
30844 }
30845
30846 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30847         LDKAcceptChannel this_ptr_conv;
30848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30849         this_ptr_conv.is_owned = false;
30850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30851         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30852         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
30853         return ret_arr;
30854 }
30855
30856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30857         LDKAcceptChannel this_ptr_conv;
30858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30859         this_ptr_conv.is_owned = false;
30860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30861         LDKThirtyTwoBytes val_ref;
30862         CHECK((*env)->GetArrayLength(env, val) == 32);
30863         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30864         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30865 }
30866
30867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30868         LDKAcceptChannel this_ptr_conv;
30869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30870         this_ptr_conv.is_owned = false;
30871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30872         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
30873         return ret_conv;
30874 }
30875
30876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30877         LDKAcceptChannel this_ptr_conv;
30878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30879         this_ptr_conv.is_owned = false;
30880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30881         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30882 }
30883
30884 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) {
30885         LDKAcceptChannel this_ptr_conv;
30886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30887         this_ptr_conv.is_owned = false;
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30889         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30890         return ret_conv;
30891 }
30892
30893 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) {
30894         LDKAcceptChannel this_ptr_conv;
30895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30896         this_ptr_conv.is_owned = false;
30897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30898         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30899 }
30900
30901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30902         LDKAcceptChannel this_ptr_conv;
30903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30904         this_ptr_conv.is_owned = false;
30905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30906         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30907         return ret_conv;
30908 }
30909
30910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30911         LDKAcceptChannel 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         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30916 }
30917
30918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30919         LDKAcceptChannel this_ptr_conv;
30920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30921         this_ptr_conv.is_owned = false;
30922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30923         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
30924         return ret_conv;
30925 }
30926
30927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30928         LDKAcceptChannel this_ptr_conv;
30929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30930         this_ptr_conv.is_owned = false;
30931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30932         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30933 }
30934
30935 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
30936         LDKAcceptChannel this_ptr_conv;
30937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30938         this_ptr_conv.is_owned = false;
30939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30940         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
30941         return ret_conv;
30942 }
30943
30944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30945         LDKAcceptChannel this_ptr_conv;
30946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30947         this_ptr_conv.is_owned = false;
30948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30949         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
30950 }
30951
30952 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30953         LDKAcceptChannel this_ptr_conv;
30954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30955         this_ptr_conv.is_owned = false;
30956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30957         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
30958         return ret_conv;
30959 }
30960
30961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30962         LDKAcceptChannel this_ptr_conv;
30963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30964         this_ptr_conv.is_owned = false;
30965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30966         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
30967 }
30968
30969 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30970         LDKAcceptChannel this_ptr_conv;
30971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30972         this_ptr_conv.is_owned = false;
30973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30974         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
30975         return ret_conv;
30976 }
30977
30978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30979         LDKAcceptChannel this_ptr_conv;
30980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30981         this_ptr_conv.is_owned = false;
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30983         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30984 }
30985
30986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30987         LDKAcceptChannel this_ptr_conv;
30988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30989         this_ptr_conv.is_owned = false;
30990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30991         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30993         return ret_arr;
30994 }
30995
30996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30997         LDKAcceptChannel this_ptr_conv;
30998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30999         this_ptr_conv.is_owned = false;
31000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31001         LDKPublicKey val_ref;
31002         CHECK((*env)->GetArrayLength(env, val) == 33);
31003         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31004         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31005 }
31006
31007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31008         LDKAcceptChannel this_ptr_conv;
31009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31010         this_ptr_conv.is_owned = false;
31011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31012         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31014         return ret_arr;
31015 }
31016
31017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31018         LDKAcceptChannel this_ptr_conv;
31019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31020         this_ptr_conv.is_owned = false;
31021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31022         LDKPublicKey val_ref;
31023         CHECK((*env)->GetArrayLength(env, val) == 33);
31024         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31025         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31026 }
31027
31028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31029         LDKAcceptChannel this_ptr_conv;
31030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31031         this_ptr_conv.is_owned = false;
31032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31033         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31034         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
31035         return ret_arr;
31036 }
31037
31038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31039         LDKAcceptChannel this_ptr_conv;
31040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31041         this_ptr_conv.is_owned = false;
31042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31043         LDKPublicKey val_ref;
31044         CHECK((*env)->GetArrayLength(env, val) == 33);
31045         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31046         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
31047 }
31048
31049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31050         LDKAcceptChannel this_ptr_conv;
31051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31052         this_ptr_conv.is_owned = false;
31053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31054         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31055         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31056         return ret_arr;
31057 }
31058
31059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31060         LDKAcceptChannel this_ptr_conv;
31061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31062         this_ptr_conv.is_owned = false;
31063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31064         LDKPublicKey val_ref;
31065         CHECK((*env)->GetArrayLength(env, val) == 33);
31066         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31067         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31068 }
31069
31070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31071         LDKAcceptChannel this_ptr_conv;
31072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31073         this_ptr_conv.is_owned = false;
31074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31075         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31076         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31077         return ret_arr;
31078 }
31079
31080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31081         LDKAcceptChannel this_ptr_conv;
31082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31083         this_ptr_conv.is_owned = false;
31084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31085         LDKPublicKey val_ref;
31086         CHECK((*env)->GetArrayLength(env, val) == 33);
31087         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31088         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31089 }
31090
31091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31092         LDKAcceptChannel this_ptr_conv;
31093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31094         this_ptr_conv.is_owned = false;
31095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31096         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31098         return ret_arr;
31099 }
31100
31101 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) {
31102         LDKAcceptChannel this_ptr_conv;
31103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31104         this_ptr_conv.is_owned = false;
31105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31106         LDKPublicKey val_ref;
31107         CHECK((*env)->GetArrayLength(env, val) == 33);
31108         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31109         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31110 }
31111
31112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31113         LDKAcceptChannel this_ptr_conv;
31114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31115         this_ptr_conv.is_owned = false;
31116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31117         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
31118         int64_t ret_ref = 0;
31119         if ((uintptr_t)ret_var.inner > 4096) {
31120                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31121                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31123                 ret_ref = (uintptr_t)ret_var.inner;
31124                 if (ret_var.is_owned) {
31125                         ret_ref |= 1;
31126                 }
31127         }
31128         return ret_ref;
31129 }
31130
31131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31132         LDKAcceptChannel this_ptr_conv;
31133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31134         this_ptr_conv.is_owned = false;
31135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31136         LDKChannelTypeFeatures val_conv;
31137         val_conv.inner = (void*)(val & (~1));
31138         val_conv.is_owned = (val & 1) || (val == 0);
31139         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31140         val_conv = ChannelTypeFeatures_clone(&val_conv);
31141         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
31142 }
31143
31144 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
31145         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
31146 int64_t ret_ref = 0;
31147 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31148 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31149 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31150 ret_ref = (uintptr_t)ret_var.inner;
31151 if (ret_var.is_owned) {
31152         ret_ref |= 1;
31153 }
31154         return ret_ref;
31155 }
31156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31157         LDKAcceptChannel arg_conv;
31158         arg_conv.inner = (void*)(arg & (~1));
31159         arg_conv.is_owned = false;
31160         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31161         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
31162         return ret_conv;
31163 }
31164
31165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31166         LDKAcceptChannel orig_conv;
31167         orig_conv.inner = (void*)(orig & (~1));
31168         orig_conv.is_owned = false;
31169         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31170         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
31171         int64_t ret_ref = 0;
31172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31175         ret_ref = (uintptr_t)ret_var.inner;
31176         if (ret_var.is_owned) {
31177                 ret_ref |= 1;
31178         }
31179         return ret_ref;
31180 }
31181
31182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31183         LDKFundingCreated this_obj_conv;
31184         this_obj_conv.inner = (void*)(this_obj & (~1));
31185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31187         FundingCreated_free(this_obj_conv);
31188 }
31189
31190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31191         LDKFundingCreated this_ptr_conv;
31192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31193         this_ptr_conv.is_owned = false;
31194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31195         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
31197         return ret_arr;
31198 }
31199
31200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31201         LDKFundingCreated this_ptr_conv;
31202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31203         this_ptr_conv.is_owned = false;
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31205         LDKThirtyTwoBytes val_ref;
31206         CHECK((*env)->GetArrayLength(env, val) == 32);
31207         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31208         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
31209 }
31210
31211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31212         LDKFundingCreated this_ptr_conv;
31213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31214         this_ptr_conv.is_owned = false;
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31216         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31217         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
31218         return ret_arr;
31219 }
31220
31221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31222         LDKFundingCreated this_ptr_conv;
31223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31224         this_ptr_conv.is_owned = false;
31225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31226         LDKThirtyTwoBytes val_ref;
31227         CHECK((*env)->GetArrayLength(env, val) == 32);
31228         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31229         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
31230 }
31231
31232 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
31233         LDKFundingCreated this_ptr_conv;
31234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31235         this_ptr_conv.is_owned = false;
31236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31237         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
31238         return ret_conv;
31239 }
31240
31241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31242         LDKFundingCreated this_ptr_conv;
31243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31244         this_ptr_conv.is_owned = false;
31245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31246         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
31247 }
31248
31249 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31250         LDKFundingCreated this_ptr_conv;
31251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31252         this_ptr_conv.is_owned = false;
31253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31254         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
31256         return ret_arr;
31257 }
31258
31259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31260         LDKFundingCreated 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         LDKSignature val_ref;
31265         CHECK((*env)->GetArrayLength(env, val) == 64);
31266         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31267         FundingCreated_set_signature(&this_ptr_conv, val_ref);
31268 }
31269
31270 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) {
31271         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
31272         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
31273         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
31274         LDKThirtyTwoBytes funding_txid_arg_ref;
31275         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
31276         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
31277         LDKSignature signature_arg_ref;
31278         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31279         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31280         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
31281         int64_t ret_ref = 0;
31282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31285         ret_ref = (uintptr_t)ret_var.inner;
31286         if (ret_var.is_owned) {
31287                 ret_ref |= 1;
31288         }
31289         return ret_ref;
31290 }
31291
31292 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
31293         LDKFundingCreated ret_var = FundingCreated_clone(arg);
31294 int64_t ret_ref = 0;
31295 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31296 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31297 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31298 ret_ref = (uintptr_t)ret_var.inner;
31299 if (ret_var.is_owned) {
31300         ret_ref |= 1;
31301 }
31302         return ret_ref;
31303 }
31304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31305         LDKFundingCreated arg_conv;
31306         arg_conv.inner = (void*)(arg & (~1));
31307         arg_conv.is_owned = false;
31308         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31309         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
31310         return ret_conv;
31311 }
31312
31313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31314         LDKFundingCreated orig_conv;
31315         orig_conv.inner = (void*)(orig & (~1));
31316         orig_conv.is_owned = false;
31317         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31318         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
31319         int64_t ret_ref = 0;
31320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31323         ret_ref = (uintptr_t)ret_var.inner;
31324         if (ret_var.is_owned) {
31325                 ret_ref |= 1;
31326         }
31327         return ret_ref;
31328 }
31329
31330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31331         LDKFundingSigned this_obj_conv;
31332         this_obj_conv.inner = (void*)(this_obj & (~1));
31333         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31335         FundingSigned_free(this_obj_conv);
31336 }
31337
31338 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31339         LDKFundingSigned this_ptr_conv;
31340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31341         this_ptr_conv.is_owned = false;
31342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31343         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31344         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
31345         return ret_arr;
31346 }
31347
31348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31349         LDKFundingSigned this_ptr_conv;
31350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31351         this_ptr_conv.is_owned = false;
31352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31353         LDKThirtyTwoBytes val_ref;
31354         CHECK((*env)->GetArrayLength(env, val) == 32);
31355         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31356         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
31357 }
31358
31359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31360         LDKFundingSigned this_ptr_conv;
31361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31362         this_ptr_conv.is_owned = false;
31363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31364         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
31366         return ret_arr;
31367 }
31368
31369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31370         LDKFundingSigned this_ptr_conv;
31371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31372         this_ptr_conv.is_owned = false;
31373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31374         LDKSignature val_ref;
31375         CHECK((*env)->GetArrayLength(env, val) == 64);
31376         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31377         FundingSigned_set_signature(&this_ptr_conv, val_ref);
31378 }
31379
31380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
31381         LDKThirtyTwoBytes channel_id_arg_ref;
31382         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31383         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31384         LDKSignature signature_arg_ref;
31385         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31386         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31387         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
31388         int64_t ret_ref = 0;
31389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31392         ret_ref = (uintptr_t)ret_var.inner;
31393         if (ret_var.is_owned) {
31394                 ret_ref |= 1;
31395         }
31396         return ret_ref;
31397 }
31398
31399 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
31400         LDKFundingSigned ret_var = FundingSigned_clone(arg);
31401 int64_t ret_ref = 0;
31402 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31403 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31404 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31405 ret_ref = (uintptr_t)ret_var.inner;
31406 if (ret_var.is_owned) {
31407         ret_ref |= 1;
31408 }
31409         return ret_ref;
31410 }
31411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31412         LDKFundingSigned arg_conv;
31413         arg_conv.inner = (void*)(arg & (~1));
31414         arg_conv.is_owned = false;
31415         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31416         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
31417         return ret_conv;
31418 }
31419
31420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31421         LDKFundingSigned orig_conv;
31422         orig_conv.inner = (void*)(orig & (~1));
31423         orig_conv.is_owned = false;
31424         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31425         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
31426         int64_t ret_ref = 0;
31427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31430         ret_ref = (uintptr_t)ret_var.inner;
31431         if (ret_var.is_owned) {
31432                 ret_ref |= 1;
31433         }
31434         return ret_ref;
31435 }
31436
31437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31438         LDKFundingLocked this_obj_conv;
31439         this_obj_conv.inner = (void*)(this_obj & (~1));
31440         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31442         FundingLocked_free(this_obj_conv);
31443 }
31444
31445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31446         LDKFundingLocked this_ptr_conv;
31447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31448         this_ptr_conv.is_owned = false;
31449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31450         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
31452         return ret_arr;
31453 }
31454
31455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31456         LDKFundingLocked this_ptr_conv;
31457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31458         this_ptr_conv.is_owned = false;
31459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31460         LDKThirtyTwoBytes val_ref;
31461         CHECK((*env)->GetArrayLength(env, val) == 32);
31462         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31463         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
31464 }
31465
31466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31467         LDKFundingLocked this_ptr_conv;
31468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31469         this_ptr_conv.is_owned = false;
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31471         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
31473         return ret_arr;
31474 }
31475
31476 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) {
31477         LDKFundingLocked this_ptr_conv;
31478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31479         this_ptr_conv.is_owned = false;
31480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31481         LDKPublicKey val_ref;
31482         CHECK((*env)->GetArrayLength(env, val) == 33);
31483         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31484         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
31485 }
31486
31487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31488         LDKFundingLocked this_ptr_conv;
31489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31490         this_ptr_conv.is_owned = false;
31491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31492         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31493         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
31494         int64_t ret_ref = (uintptr_t)ret_copy;
31495         return ret_ref;
31496 }
31497
31498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31499         LDKFundingLocked this_ptr_conv;
31500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31501         this_ptr_conv.is_owned = false;
31502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31503         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31504         CHECK_ACCESS(val_ptr);
31505         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31506         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
31507         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
31508 }
31509
31510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
31511         LDKThirtyTwoBytes channel_id_arg_ref;
31512         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31513         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31514         LDKPublicKey next_per_commitment_point_arg_ref;
31515         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
31516         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
31517         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
31518         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
31519         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
31520         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
31521         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
31522         int64_t ret_ref = 0;
31523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31526         ret_ref = (uintptr_t)ret_var.inner;
31527         if (ret_var.is_owned) {
31528                 ret_ref |= 1;
31529         }
31530         return ret_ref;
31531 }
31532
31533 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
31534         LDKFundingLocked ret_var = FundingLocked_clone(arg);
31535 int64_t ret_ref = 0;
31536 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31537 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31538 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31539 ret_ref = (uintptr_t)ret_var.inner;
31540 if (ret_var.is_owned) {
31541         ret_ref |= 1;
31542 }
31543         return ret_ref;
31544 }
31545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31546         LDKFundingLocked arg_conv;
31547         arg_conv.inner = (void*)(arg & (~1));
31548         arg_conv.is_owned = false;
31549         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31550         int64_t ret_conv = FundingLocked_clone_ptr(&arg_conv);
31551         return ret_conv;
31552 }
31553
31554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31555         LDKFundingLocked orig_conv;
31556         orig_conv.inner = (void*)(orig & (~1));
31557         orig_conv.is_owned = false;
31558         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31559         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
31560         int64_t ret_ref = 0;
31561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31564         ret_ref = (uintptr_t)ret_var.inner;
31565         if (ret_var.is_owned) {
31566                 ret_ref |= 1;
31567         }
31568         return ret_ref;
31569 }
31570
31571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31572         LDKShutdown this_obj_conv;
31573         this_obj_conv.inner = (void*)(this_obj & (~1));
31574         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31576         Shutdown_free(this_obj_conv);
31577 }
31578
31579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31580         LDKShutdown this_ptr_conv;
31581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31582         this_ptr_conv.is_owned = false;
31583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31584         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
31586         return ret_arr;
31587 }
31588
31589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31590         LDKShutdown this_ptr_conv;
31591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31592         this_ptr_conv.is_owned = false;
31593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31594         LDKThirtyTwoBytes val_ref;
31595         CHECK((*env)->GetArrayLength(env, val) == 32);
31596         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31597         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
31598 }
31599
31600 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31601         LDKShutdown this_ptr_conv;
31602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31603         this_ptr_conv.is_owned = false;
31604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31605         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
31606         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31607         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31608         return ret_arr;
31609 }
31610
31611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31612         LDKShutdown this_ptr_conv;
31613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31614         this_ptr_conv.is_owned = false;
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31616         LDKCVec_u8Z val_ref;
31617         val_ref.datalen = (*env)->GetArrayLength(env, val);
31618         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31619         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
31620         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
31621 }
31622
31623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
31624         LDKThirtyTwoBytes channel_id_arg_ref;
31625         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31626         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31627         LDKCVec_u8Z scriptpubkey_arg_ref;
31628         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
31629         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31630         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
31631         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
31632         int64_t ret_ref = 0;
31633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31636         ret_ref = (uintptr_t)ret_var.inner;
31637         if (ret_var.is_owned) {
31638                 ret_ref |= 1;
31639         }
31640         return ret_ref;
31641 }
31642
31643 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
31644         LDKShutdown ret_var = Shutdown_clone(arg);
31645 int64_t ret_ref = 0;
31646 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31647 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31648 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31649 ret_ref = (uintptr_t)ret_var.inner;
31650 if (ret_var.is_owned) {
31651         ret_ref |= 1;
31652 }
31653         return ret_ref;
31654 }
31655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31656         LDKShutdown arg_conv;
31657         arg_conv.inner = (void*)(arg & (~1));
31658         arg_conv.is_owned = false;
31659         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31660         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
31661         return ret_conv;
31662 }
31663
31664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31665         LDKShutdown orig_conv;
31666         orig_conv.inner = (void*)(orig & (~1));
31667         orig_conv.is_owned = false;
31668         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31669         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
31670         int64_t ret_ref = 0;
31671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31674         ret_ref = (uintptr_t)ret_var.inner;
31675         if (ret_var.is_owned) {
31676                 ret_ref |= 1;
31677         }
31678         return ret_ref;
31679 }
31680
31681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31682         LDKClosingSignedFeeRange this_obj_conv;
31683         this_obj_conv.inner = (void*)(this_obj & (~1));
31684         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31686         ClosingSignedFeeRange_free(this_obj_conv);
31687 }
31688
31689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31690         LDKClosingSignedFeeRange this_ptr_conv;
31691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31692         this_ptr_conv.is_owned = false;
31693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31694         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
31695         return ret_conv;
31696 }
31697
31698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31699         LDKClosingSignedFeeRange this_ptr_conv;
31700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31701         this_ptr_conv.is_owned = false;
31702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31703         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
31704 }
31705
31706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31707         LDKClosingSignedFeeRange this_ptr_conv;
31708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31709         this_ptr_conv.is_owned = false;
31710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31711         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
31712         return ret_conv;
31713 }
31714
31715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31716         LDKClosingSignedFeeRange this_ptr_conv;
31717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31718         this_ptr_conv.is_owned = false;
31719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31720         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
31721 }
31722
31723 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) {
31724         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
31725         int64_t ret_ref = 0;
31726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31729         ret_ref = (uintptr_t)ret_var.inner;
31730         if (ret_var.is_owned) {
31731                 ret_ref |= 1;
31732         }
31733         return ret_ref;
31734 }
31735
31736 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
31737         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
31738 int64_t ret_ref = 0;
31739 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31740 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31741 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31742 ret_ref = (uintptr_t)ret_var.inner;
31743 if (ret_var.is_owned) {
31744         ret_ref |= 1;
31745 }
31746         return ret_ref;
31747 }
31748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31749         LDKClosingSignedFeeRange arg_conv;
31750         arg_conv.inner = (void*)(arg & (~1));
31751         arg_conv.is_owned = false;
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31753         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
31754         return ret_conv;
31755 }
31756
31757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31758         LDKClosingSignedFeeRange orig_conv;
31759         orig_conv.inner = (void*)(orig & (~1));
31760         orig_conv.is_owned = false;
31761         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31762         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
31763         int64_t ret_ref = 0;
31764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31767         ret_ref = (uintptr_t)ret_var.inner;
31768         if (ret_var.is_owned) {
31769                 ret_ref |= 1;
31770         }
31771         return ret_ref;
31772 }
31773
31774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31775         LDKClosingSigned this_obj_conv;
31776         this_obj_conv.inner = (void*)(this_obj & (~1));
31777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31779         ClosingSigned_free(this_obj_conv);
31780 }
31781
31782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31783         LDKClosingSigned this_ptr_conv;
31784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31785         this_ptr_conv.is_owned = false;
31786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31787         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
31789         return ret_arr;
31790 }
31791
31792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31793         LDKClosingSigned this_ptr_conv;
31794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31795         this_ptr_conv.is_owned = false;
31796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31797         LDKThirtyTwoBytes val_ref;
31798         CHECK((*env)->GetArrayLength(env, val) == 32);
31799         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31800         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
31801 }
31802
31803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31804         LDKClosingSigned this_ptr_conv;
31805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31806         this_ptr_conv.is_owned = false;
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31808         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
31809         return ret_conv;
31810 }
31811
31812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31813         LDKClosingSigned this_ptr_conv;
31814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31815         this_ptr_conv.is_owned = false;
31816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31817         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
31818 }
31819
31820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31821         LDKClosingSigned this_ptr_conv;
31822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31823         this_ptr_conv.is_owned = false;
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31825         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31826         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
31827         return ret_arr;
31828 }
31829
31830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31831         LDKClosingSigned this_ptr_conv;
31832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31833         this_ptr_conv.is_owned = false;
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31835         LDKSignature val_ref;
31836         CHECK((*env)->GetArrayLength(env, val) == 64);
31837         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31838         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
31839 }
31840
31841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
31842         LDKClosingSigned this_ptr_conv;
31843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31844         this_ptr_conv.is_owned = false;
31845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31846         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
31847         int64_t ret_ref = 0;
31848         if ((uintptr_t)ret_var.inner > 4096) {
31849                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31850                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31852                 ret_ref = (uintptr_t)ret_var.inner;
31853                 if (ret_var.is_owned) {
31854                         ret_ref |= 1;
31855                 }
31856         }
31857         return ret_ref;
31858 }
31859
31860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31861         LDKClosingSigned this_ptr_conv;
31862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31863         this_ptr_conv.is_owned = false;
31864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31865         LDKClosingSignedFeeRange val_conv;
31866         val_conv.inner = (void*)(val & (~1));
31867         val_conv.is_owned = (val & 1) || (val == 0);
31868         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31869         val_conv = ClosingSignedFeeRange_clone(&val_conv);
31870         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
31871 }
31872
31873 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) {
31874         LDKThirtyTwoBytes channel_id_arg_ref;
31875         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31876         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31877         LDKSignature signature_arg_ref;
31878         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31879         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31880         LDKClosingSignedFeeRange fee_range_arg_conv;
31881         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
31882         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
31883         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
31884         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
31885         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
31886         int64_t ret_ref = 0;
31887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31890         ret_ref = (uintptr_t)ret_var.inner;
31891         if (ret_var.is_owned) {
31892                 ret_ref |= 1;
31893         }
31894         return ret_ref;
31895 }
31896
31897 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
31898         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
31899 int64_t ret_ref = 0;
31900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31903 ret_ref = (uintptr_t)ret_var.inner;
31904 if (ret_var.is_owned) {
31905         ret_ref |= 1;
31906 }
31907         return ret_ref;
31908 }
31909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31910         LDKClosingSigned arg_conv;
31911         arg_conv.inner = (void*)(arg & (~1));
31912         arg_conv.is_owned = false;
31913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31914         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
31915         return ret_conv;
31916 }
31917
31918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31919         LDKClosingSigned orig_conv;
31920         orig_conv.inner = (void*)(orig & (~1));
31921         orig_conv.is_owned = false;
31922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31923         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
31924         int64_t ret_ref = 0;
31925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31928         ret_ref = (uintptr_t)ret_var.inner;
31929         if (ret_var.is_owned) {
31930                 ret_ref |= 1;
31931         }
31932         return ret_ref;
31933 }
31934
31935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31936         LDKUpdateAddHTLC this_obj_conv;
31937         this_obj_conv.inner = (void*)(this_obj & (~1));
31938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31940         UpdateAddHTLC_free(this_obj_conv);
31941 }
31942
31943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31944         LDKUpdateAddHTLC this_ptr_conv;
31945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31946         this_ptr_conv.is_owned = false;
31947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31948         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
31950         return ret_arr;
31951 }
31952
31953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31954         LDKUpdateAddHTLC this_ptr_conv;
31955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31956         this_ptr_conv.is_owned = false;
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31958         LDKThirtyTwoBytes val_ref;
31959         CHECK((*env)->GetArrayLength(env, val) == 32);
31960         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31961         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
31962 }
31963
31964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31965         LDKUpdateAddHTLC this_ptr_conv;
31966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31967         this_ptr_conv.is_owned = false;
31968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31969         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
31970         return ret_conv;
31971 }
31972
31973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31974         LDKUpdateAddHTLC this_ptr_conv;
31975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31976         this_ptr_conv.is_owned = false;
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31978         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
31979 }
31980
31981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31982         LDKUpdateAddHTLC this_ptr_conv;
31983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31984         this_ptr_conv.is_owned = false;
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31986         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
31987         return ret_conv;
31988 }
31989
31990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31991         LDKUpdateAddHTLC this_ptr_conv;
31992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31993         this_ptr_conv.is_owned = false;
31994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31995         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
31996 }
31997
31998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31999         LDKUpdateAddHTLC this_ptr_conv;
32000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32001         this_ptr_conv.is_owned = false;
32002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32003         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
32005         return ret_arr;
32006 }
32007
32008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32009         LDKUpdateAddHTLC this_ptr_conv;
32010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32011         this_ptr_conv.is_owned = false;
32012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32013         LDKThirtyTwoBytes val_ref;
32014         CHECK((*env)->GetArrayLength(env, val) == 32);
32015         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32016         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
32017 }
32018
32019 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
32020         LDKUpdateAddHTLC this_ptr_conv;
32021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32022         this_ptr_conv.is_owned = false;
32023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32024         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
32025         return ret_conv;
32026 }
32027
32028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32029         LDKUpdateAddHTLC this_ptr_conv;
32030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32031         this_ptr_conv.is_owned = false;
32032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32033         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
32034 }
32035
32036 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
32037         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
32038 int64_t ret_ref = 0;
32039 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32040 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32041 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32042 ret_ref = (uintptr_t)ret_var.inner;
32043 if (ret_var.is_owned) {
32044         ret_ref |= 1;
32045 }
32046         return ret_ref;
32047 }
32048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32049         LDKUpdateAddHTLC arg_conv;
32050         arg_conv.inner = (void*)(arg & (~1));
32051         arg_conv.is_owned = false;
32052         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32053         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
32054         return ret_conv;
32055 }
32056
32057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32058         LDKUpdateAddHTLC orig_conv;
32059         orig_conv.inner = (void*)(orig & (~1));
32060         orig_conv.is_owned = false;
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32062         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
32063         int64_t ret_ref = 0;
32064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32067         ret_ref = (uintptr_t)ret_var.inner;
32068         if (ret_var.is_owned) {
32069                 ret_ref |= 1;
32070         }
32071         return ret_ref;
32072 }
32073
32074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32075         LDKUpdateFulfillHTLC this_obj_conv;
32076         this_obj_conv.inner = (void*)(this_obj & (~1));
32077         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32079         UpdateFulfillHTLC_free(this_obj_conv);
32080 }
32081
32082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32083         LDKUpdateFulfillHTLC this_ptr_conv;
32084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32085         this_ptr_conv.is_owned = false;
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32088         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
32089         return ret_arr;
32090 }
32091
32092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32093         LDKUpdateFulfillHTLC this_ptr_conv;
32094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32095         this_ptr_conv.is_owned = false;
32096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32097         LDKThirtyTwoBytes val_ref;
32098         CHECK((*env)->GetArrayLength(env, val) == 32);
32099         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32100         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
32101 }
32102
32103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32104         LDKUpdateFulfillHTLC this_ptr_conv;
32105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32106         this_ptr_conv.is_owned = false;
32107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32108         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
32109         return ret_conv;
32110 }
32111
32112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32113         LDKUpdateFulfillHTLC this_ptr_conv;
32114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32115         this_ptr_conv.is_owned = false;
32116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32117         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
32118 }
32119
32120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
32121         LDKUpdateFulfillHTLC this_ptr_conv;
32122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32123         this_ptr_conv.is_owned = false;
32124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32125         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
32127         return ret_arr;
32128 }
32129
32130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32131         LDKUpdateFulfillHTLC this_ptr_conv;
32132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32133         this_ptr_conv.is_owned = false;
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32135         LDKThirtyTwoBytes val_ref;
32136         CHECK((*env)->GetArrayLength(env, val) == 32);
32137         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32138         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
32139 }
32140
32141 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) {
32142         LDKThirtyTwoBytes channel_id_arg_ref;
32143         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32144         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32145         LDKThirtyTwoBytes payment_preimage_arg_ref;
32146         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
32147         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
32148         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
32149         int64_t ret_ref = 0;
32150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32153         ret_ref = (uintptr_t)ret_var.inner;
32154         if (ret_var.is_owned) {
32155                 ret_ref |= 1;
32156         }
32157         return ret_ref;
32158 }
32159
32160 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
32161         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
32162 int64_t ret_ref = 0;
32163 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32164 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32165 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32166 ret_ref = (uintptr_t)ret_var.inner;
32167 if (ret_var.is_owned) {
32168         ret_ref |= 1;
32169 }
32170         return ret_ref;
32171 }
32172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32173         LDKUpdateFulfillHTLC arg_conv;
32174         arg_conv.inner = (void*)(arg & (~1));
32175         arg_conv.is_owned = false;
32176         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32177         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
32178         return ret_conv;
32179 }
32180
32181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32182         LDKUpdateFulfillHTLC orig_conv;
32183         orig_conv.inner = (void*)(orig & (~1));
32184         orig_conv.is_owned = false;
32185         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32186         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
32187         int64_t ret_ref = 0;
32188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32191         ret_ref = (uintptr_t)ret_var.inner;
32192         if (ret_var.is_owned) {
32193                 ret_ref |= 1;
32194         }
32195         return ret_ref;
32196 }
32197
32198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32199         LDKUpdateFailHTLC this_obj_conv;
32200         this_obj_conv.inner = (void*)(this_obj & (~1));
32201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32203         UpdateFailHTLC_free(this_obj_conv);
32204 }
32205
32206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32207         LDKUpdateFailHTLC this_ptr_conv;
32208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32209         this_ptr_conv.is_owned = false;
32210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32211         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32212         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
32213         return ret_arr;
32214 }
32215
32216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32217         LDKUpdateFailHTLC this_ptr_conv;
32218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32219         this_ptr_conv.is_owned = false;
32220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32221         LDKThirtyTwoBytes val_ref;
32222         CHECK((*env)->GetArrayLength(env, val) == 32);
32223         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32224         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
32225 }
32226
32227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32228         LDKUpdateFailHTLC this_ptr_conv;
32229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32230         this_ptr_conv.is_owned = false;
32231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32232         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
32233         return ret_conv;
32234 }
32235
32236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32237         LDKUpdateFailHTLC this_ptr_conv;
32238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32239         this_ptr_conv.is_owned = false;
32240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32241         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
32242 }
32243
32244 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
32245         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
32246 int64_t ret_ref = 0;
32247 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32248 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32249 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32250 ret_ref = (uintptr_t)ret_var.inner;
32251 if (ret_var.is_owned) {
32252         ret_ref |= 1;
32253 }
32254         return ret_ref;
32255 }
32256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32257         LDKUpdateFailHTLC arg_conv;
32258         arg_conv.inner = (void*)(arg & (~1));
32259         arg_conv.is_owned = false;
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32261         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
32262         return ret_conv;
32263 }
32264
32265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32266         LDKUpdateFailHTLC orig_conv;
32267         orig_conv.inner = (void*)(orig & (~1));
32268         orig_conv.is_owned = false;
32269         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32270         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
32271         int64_t ret_ref = 0;
32272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32275         ret_ref = (uintptr_t)ret_var.inner;
32276         if (ret_var.is_owned) {
32277                 ret_ref |= 1;
32278         }
32279         return ret_ref;
32280 }
32281
32282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32283         LDKUpdateFailMalformedHTLC this_obj_conv;
32284         this_obj_conv.inner = (void*)(this_obj & (~1));
32285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32287         UpdateFailMalformedHTLC_free(this_obj_conv);
32288 }
32289
32290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32291         LDKUpdateFailMalformedHTLC this_ptr_conv;
32292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32293         this_ptr_conv.is_owned = false;
32294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32295         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32296         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
32297         return ret_arr;
32298 }
32299
32300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32301         LDKUpdateFailMalformedHTLC this_ptr_conv;
32302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32303         this_ptr_conv.is_owned = false;
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32305         LDKThirtyTwoBytes val_ref;
32306         CHECK((*env)->GetArrayLength(env, val) == 32);
32307         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32308         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
32309 }
32310
32311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32312         LDKUpdateFailMalformedHTLC this_ptr_conv;
32313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32314         this_ptr_conv.is_owned = false;
32315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32316         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
32317         return ret_conv;
32318 }
32319
32320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32321         LDKUpdateFailMalformedHTLC this_ptr_conv;
32322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32323         this_ptr_conv.is_owned = false;
32324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32325         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
32326 }
32327
32328 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
32329         LDKUpdateFailMalformedHTLC this_ptr_conv;
32330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32331         this_ptr_conv.is_owned = false;
32332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32333         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
32334         return ret_conv;
32335 }
32336
32337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32338         LDKUpdateFailMalformedHTLC this_ptr_conv;
32339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32340         this_ptr_conv.is_owned = false;
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32342         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
32343 }
32344
32345 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
32346         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
32347 int64_t ret_ref = 0;
32348 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32349 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32350 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32351 ret_ref = (uintptr_t)ret_var.inner;
32352 if (ret_var.is_owned) {
32353         ret_ref |= 1;
32354 }
32355         return ret_ref;
32356 }
32357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32358         LDKUpdateFailMalformedHTLC arg_conv;
32359         arg_conv.inner = (void*)(arg & (~1));
32360         arg_conv.is_owned = false;
32361         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32362         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
32363         return ret_conv;
32364 }
32365
32366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32367         LDKUpdateFailMalformedHTLC orig_conv;
32368         orig_conv.inner = (void*)(orig & (~1));
32369         orig_conv.is_owned = false;
32370         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32371         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
32372         int64_t ret_ref = 0;
32373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32376         ret_ref = (uintptr_t)ret_var.inner;
32377         if (ret_var.is_owned) {
32378                 ret_ref |= 1;
32379         }
32380         return ret_ref;
32381 }
32382
32383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32384         LDKCommitmentSigned this_obj_conv;
32385         this_obj_conv.inner = (void*)(this_obj & (~1));
32386         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32388         CommitmentSigned_free(this_obj_conv);
32389 }
32390
32391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32392         LDKCommitmentSigned this_ptr_conv;
32393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32394         this_ptr_conv.is_owned = false;
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
32398         return ret_arr;
32399 }
32400
32401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32402         LDKCommitmentSigned this_ptr_conv;
32403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32404         this_ptr_conv.is_owned = false;
32405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32406         LDKThirtyTwoBytes val_ref;
32407         CHECK((*env)->GetArrayLength(env, val) == 32);
32408         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32409         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
32410 }
32411
32412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32413         LDKCommitmentSigned this_ptr_conv;
32414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32415         this_ptr_conv.is_owned = false;
32416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32417         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
32419         return ret_arr;
32420 }
32421
32422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32423         LDKCommitmentSigned this_ptr_conv;
32424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32425         this_ptr_conv.is_owned = false;
32426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32427         LDKSignature val_ref;
32428         CHECK((*env)->GetArrayLength(env, val) == 64);
32429         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32430         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
32431 }
32432
32433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
32434         LDKCommitmentSigned this_ptr_conv;
32435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32436         this_ptr_conv.is_owned = false;
32437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32438         LDKCVec_SignatureZ val_constr;
32439         val_constr.datalen = (*env)->GetArrayLength(env, val);
32440         if (val_constr.datalen > 0)
32441                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32442         else
32443                 val_constr.data = NULL;
32444         for (size_t i = 0; i < val_constr.datalen; i++) {
32445                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
32446                 LDKSignature val_conv_8_ref;
32447                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
32448                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
32449                 val_constr.data[i] = val_conv_8_ref;
32450         }
32451         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
32452 }
32453
32454 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) {
32455         LDKThirtyTwoBytes channel_id_arg_ref;
32456         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32457         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32458         LDKSignature signature_arg_ref;
32459         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32460         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32461         LDKCVec_SignatureZ htlc_signatures_arg_constr;
32462         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
32463         if (htlc_signatures_arg_constr.datalen > 0)
32464                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32465         else
32466                 htlc_signatures_arg_constr.data = NULL;
32467         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
32468                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
32469                 LDKSignature htlc_signatures_arg_conv_8_ref;
32470                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
32471                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
32472                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
32473         }
32474         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
32475         int64_t ret_ref = 0;
32476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32479         ret_ref = (uintptr_t)ret_var.inner;
32480         if (ret_var.is_owned) {
32481                 ret_ref |= 1;
32482         }
32483         return ret_ref;
32484 }
32485
32486 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
32487         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
32488 int64_t ret_ref = 0;
32489 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32490 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32491 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32492 ret_ref = (uintptr_t)ret_var.inner;
32493 if (ret_var.is_owned) {
32494         ret_ref |= 1;
32495 }
32496         return ret_ref;
32497 }
32498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32499         LDKCommitmentSigned arg_conv;
32500         arg_conv.inner = (void*)(arg & (~1));
32501         arg_conv.is_owned = false;
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32503         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
32504         return ret_conv;
32505 }
32506
32507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32508         LDKCommitmentSigned orig_conv;
32509         orig_conv.inner = (void*)(orig & (~1));
32510         orig_conv.is_owned = false;
32511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32512         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
32513         int64_t ret_ref = 0;
32514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32517         ret_ref = (uintptr_t)ret_var.inner;
32518         if (ret_var.is_owned) {
32519                 ret_ref |= 1;
32520         }
32521         return ret_ref;
32522 }
32523
32524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32525         LDKRevokeAndACK this_obj_conv;
32526         this_obj_conv.inner = (void*)(this_obj & (~1));
32527         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32529         RevokeAndACK_free(this_obj_conv);
32530 }
32531
32532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32533         LDKRevokeAndACK this_ptr_conv;
32534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32535         this_ptr_conv.is_owned = false;
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32537         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
32539         return ret_arr;
32540 }
32541
32542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32543         LDKRevokeAndACK this_ptr_conv;
32544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32545         this_ptr_conv.is_owned = false;
32546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32547         LDKThirtyTwoBytes val_ref;
32548         CHECK((*env)->GetArrayLength(env, val) == 32);
32549         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32550         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
32551 }
32552
32553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32554         LDKRevokeAndACK this_ptr_conv;
32555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32556         this_ptr_conv.is_owned = false;
32557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32558         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
32560         return ret_arr;
32561 }
32562
32563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32564         LDKRevokeAndACK this_ptr_conv;
32565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32566         this_ptr_conv.is_owned = false;
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         LDKThirtyTwoBytes val_ref;
32569         CHECK((*env)->GetArrayLength(env, val) == 32);
32570         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32571         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
32572 }
32573
32574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32575         LDKRevokeAndACK this_ptr_conv;
32576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32577         this_ptr_conv.is_owned = false;
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32579         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32581         return ret_arr;
32582 }
32583
32584 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) {
32585         LDKRevokeAndACK this_ptr_conv;
32586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32587         this_ptr_conv.is_owned = false;
32588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32589         LDKPublicKey val_ref;
32590         CHECK((*env)->GetArrayLength(env, val) == 33);
32591         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32592         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32593 }
32594
32595 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) {
32596         LDKThirtyTwoBytes channel_id_arg_ref;
32597         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32598         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32599         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
32600         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
32601         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
32602         LDKPublicKey next_per_commitment_point_arg_ref;
32603         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32604         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32605         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
32606         int64_t ret_ref = 0;
32607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32610         ret_ref = (uintptr_t)ret_var.inner;
32611         if (ret_var.is_owned) {
32612                 ret_ref |= 1;
32613         }
32614         return ret_ref;
32615 }
32616
32617 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
32618         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
32619 int64_t ret_ref = 0;
32620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32623 ret_ref = (uintptr_t)ret_var.inner;
32624 if (ret_var.is_owned) {
32625         ret_ref |= 1;
32626 }
32627         return ret_ref;
32628 }
32629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32630         LDKRevokeAndACK arg_conv;
32631         arg_conv.inner = (void*)(arg & (~1));
32632         arg_conv.is_owned = false;
32633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32634         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
32635         return ret_conv;
32636 }
32637
32638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32639         LDKRevokeAndACK orig_conv;
32640         orig_conv.inner = (void*)(orig & (~1));
32641         orig_conv.is_owned = false;
32642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32643         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
32644         int64_t ret_ref = 0;
32645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32648         ret_ref = (uintptr_t)ret_var.inner;
32649         if (ret_var.is_owned) {
32650                 ret_ref |= 1;
32651         }
32652         return ret_ref;
32653 }
32654
32655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32656         LDKUpdateFee this_obj_conv;
32657         this_obj_conv.inner = (void*)(this_obj & (~1));
32658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32660         UpdateFee_free(this_obj_conv);
32661 }
32662
32663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32664         LDKUpdateFee this_ptr_conv;
32665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32666         this_ptr_conv.is_owned = false;
32667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32668         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
32670         return ret_arr;
32671 }
32672
32673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32674         LDKUpdateFee this_ptr_conv;
32675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32676         this_ptr_conv.is_owned = false;
32677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32678         LDKThirtyTwoBytes val_ref;
32679         CHECK((*env)->GetArrayLength(env, val) == 32);
32680         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32681         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
32682 }
32683
32684 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32685         LDKUpdateFee this_ptr_conv;
32686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32687         this_ptr_conv.is_owned = false;
32688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32689         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
32690         return ret_conv;
32691 }
32692
32693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32694         LDKUpdateFee this_ptr_conv;
32695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32696         this_ptr_conv.is_owned = false;
32697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32698         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
32699 }
32700
32701 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) {
32702         LDKThirtyTwoBytes channel_id_arg_ref;
32703         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32704         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32705         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
32706         int64_t ret_ref = 0;
32707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32710         ret_ref = (uintptr_t)ret_var.inner;
32711         if (ret_var.is_owned) {
32712                 ret_ref |= 1;
32713         }
32714         return ret_ref;
32715 }
32716
32717 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
32718         LDKUpdateFee ret_var = UpdateFee_clone(arg);
32719 int64_t ret_ref = 0;
32720 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32721 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32722 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32723 ret_ref = (uintptr_t)ret_var.inner;
32724 if (ret_var.is_owned) {
32725         ret_ref |= 1;
32726 }
32727         return ret_ref;
32728 }
32729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32730         LDKUpdateFee arg_conv;
32731         arg_conv.inner = (void*)(arg & (~1));
32732         arg_conv.is_owned = false;
32733         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32734         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
32735         return ret_conv;
32736 }
32737
32738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32739         LDKUpdateFee orig_conv;
32740         orig_conv.inner = (void*)(orig & (~1));
32741         orig_conv.is_owned = false;
32742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32743         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
32744         int64_t ret_ref = 0;
32745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32748         ret_ref = (uintptr_t)ret_var.inner;
32749         if (ret_var.is_owned) {
32750                 ret_ref |= 1;
32751         }
32752         return ret_ref;
32753 }
32754
32755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32756         LDKDataLossProtect this_obj_conv;
32757         this_obj_conv.inner = (void*)(this_obj & (~1));
32758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32760         DataLossProtect_free(this_obj_conv);
32761 }
32762
32763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32764         LDKDataLossProtect this_ptr_conv;
32765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32766         this_ptr_conv.is_owned = false;
32767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32768         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
32770         return ret_arr;
32771 }
32772
32773 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) {
32774         LDKDataLossProtect this_ptr_conv;
32775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32776         this_ptr_conv.is_owned = false;
32777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32778         LDKThirtyTwoBytes val_ref;
32779         CHECK((*env)->GetArrayLength(env, val) == 32);
32780         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32781         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
32782 }
32783
32784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32785         LDKDataLossProtect this_ptr_conv;
32786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32787         this_ptr_conv.is_owned = false;
32788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32789         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
32791         return ret_arr;
32792 }
32793
32794 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) {
32795         LDKDataLossProtect this_ptr_conv;
32796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32797         this_ptr_conv.is_owned = false;
32798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32799         LDKPublicKey val_ref;
32800         CHECK((*env)->GetArrayLength(env, val) == 33);
32801         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32802         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
32803 }
32804
32805 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) {
32806         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
32807         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
32808         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
32809         LDKPublicKey my_current_per_commitment_point_arg_ref;
32810         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
32811         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
32812         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
32813         int64_t ret_ref = 0;
32814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32817         ret_ref = (uintptr_t)ret_var.inner;
32818         if (ret_var.is_owned) {
32819                 ret_ref |= 1;
32820         }
32821         return ret_ref;
32822 }
32823
32824 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
32825         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
32826 int64_t ret_ref = 0;
32827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32830 ret_ref = (uintptr_t)ret_var.inner;
32831 if (ret_var.is_owned) {
32832         ret_ref |= 1;
32833 }
32834         return ret_ref;
32835 }
32836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32837         LDKDataLossProtect arg_conv;
32838         arg_conv.inner = (void*)(arg & (~1));
32839         arg_conv.is_owned = false;
32840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32841         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
32842         return ret_conv;
32843 }
32844
32845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32846         LDKDataLossProtect orig_conv;
32847         orig_conv.inner = (void*)(orig & (~1));
32848         orig_conv.is_owned = false;
32849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32850         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
32851         int64_t ret_ref = 0;
32852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32855         ret_ref = (uintptr_t)ret_var.inner;
32856         if (ret_var.is_owned) {
32857                 ret_ref |= 1;
32858         }
32859         return ret_ref;
32860 }
32861
32862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32863         LDKChannelReestablish this_obj_conv;
32864         this_obj_conv.inner = (void*)(this_obj & (~1));
32865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32867         ChannelReestablish_free(this_obj_conv);
32868 }
32869
32870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32871         LDKChannelReestablish this_ptr_conv;
32872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32873         this_ptr_conv.is_owned = false;
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
32877         return ret_arr;
32878 }
32879
32880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32881         LDKChannelReestablish this_ptr_conv;
32882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32883         this_ptr_conv.is_owned = false;
32884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32885         LDKThirtyTwoBytes val_ref;
32886         CHECK((*env)->GetArrayLength(env, val) == 32);
32887         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32888         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
32889 }
32890
32891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32892         LDKChannelReestablish this_ptr_conv;
32893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32894         this_ptr_conv.is_owned = false;
32895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32896         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
32897         return ret_conv;
32898 }
32899
32900 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) {
32901         LDKChannelReestablish this_ptr_conv;
32902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32903         this_ptr_conv.is_owned = false;
32904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32905         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
32906 }
32907
32908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32909         LDKChannelReestablish this_ptr_conv;
32910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32911         this_ptr_conv.is_owned = false;
32912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32913         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
32914         return ret_conv;
32915 }
32916
32917 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) {
32918         LDKChannelReestablish this_ptr_conv;
32919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32920         this_ptr_conv.is_owned = false;
32921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32922         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
32923 }
32924
32925 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
32926         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
32927 int64_t ret_ref = 0;
32928 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32929 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32930 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32931 ret_ref = (uintptr_t)ret_var.inner;
32932 if (ret_var.is_owned) {
32933         ret_ref |= 1;
32934 }
32935         return ret_ref;
32936 }
32937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32938         LDKChannelReestablish arg_conv;
32939         arg_conv.inner = (void*)(arg & (~1));
32940         arg_conv.is_owned = false;
32941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32942         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
32943         return ret_conv;
32944 }
32945
32946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32947         LDKChannelReestablish orig_conv;
32948         orig_conv.inner = (void*)(orig & (~1));
32949         orig_conv.is_owned = false;
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32951         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
32952         int64_t ret_ref = 0;
32953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32956         ret_ref = (uintptr_t)ret_var.inner;
32957         if (ret_var.is_owned) {
32958                 ret_ref |= 1;
32959         }
32960         return ret_ref;
32961 }
32962
32963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32964         LDKAnnouncementSignatures this_obj_conv;
32965         this_obj_conv.inner = (void*)(this_obj & (~1));
32966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32968         AnnouncementSignatures_free(this_obj_conv);
32969 }
32970
32971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32972         LDKAnnouncementSignatures this_ptr_conv;
32973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32974         this_ptr_conv.is_owned = false;
32975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32976         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
32978         return ret_arr;
32979 }
32980
32981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32982         LDKAnnouncementSignatures this_ptr_conv;
32983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32984         this_ptr_conv.is_owned = false;
32985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32986         LDKThirtyTwoBytes val_ref;
32987         CHECK((*env)->GetArrayLength(env, val) == 32);
32988         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32989         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
32990 }
32991
32992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32993         LDKAnnouncementSignatures this_ptr_conv;
32994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32995         this_ptr_conv.is_owned = false;
32996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32997         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
32998         return ret_conv;
32999 }
33000
33001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33002         LDKAnnouncementSignatures this_ptr_conv;
33003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33004         this_ptr_conv.is_owned = false;
33005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33006         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
33007 }
33008
33009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33010         LDKAnnouncementSignatures 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
33016         return ret_arr;
33017 }
33018
33019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33020         LDKAnnouncementSignatures this_ptr_conv;
33021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33022         this_ptr_conv.is_owned = false;
33023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33024         LDKSignature val_ref;
33025         CHECK((*env)->GetArrayLength(env, val) == 64);
33026         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33027         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
33028 }
33029
33030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33031         LDKAnnouncementSignatures this_ptr_conv;
33032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33033         this_ptr_conv.is_owned = false;
33034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33035         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
33037         return ret_arr;
33038 }
33039
33040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33041         LDKAnnouncementSignatures this_ptr_conv;
33042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33043         this_ptr_conv.is_owned = false;
33044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33045         LDKSignature val_ref;
33046         CHECK((*env)->GetArrayLength(env, val) == 64);
33047         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33048         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
33049 }
33050
33051 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) {
33052         LDKThirtyTwoBytes channel_id_arg_ref;
33053         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33054         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33055         LDKSignature node_signature_arg_ref;
33056         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
33057         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
33058         LDKSignature bitcoin_signature_arg_ref;
33059         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
33060         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
33061         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
33062         int64_t ret_ref = 0;
33063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33066         ret_ref = (uintptr_t)ret_var.inner;
33067         if (ret_var.is_owned) {
33068                 ret_ref |= 1;
33069         }
33070         return ret_ref;
33071 }
33072
33073 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
33074         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
33075 int64_t ret_ref = 0;
33076 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33077 CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
33080 if (ret_var.is_owned) {
33081         ret_ref |= 1;
33082 }
33083         return ret_ref;
33084 }
33085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33086         LDKAnnouncementSignatures arg_conv;
33087         arg_conv.inner = (void*)(arg & (~1));
33088         arg_conv.is_owned = false;
33089         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33090         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
33091         return ret_conv;
33092 }
33093
33094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33095         LDKAnnouncementSignatures orig_conv;
33096         orig_conv.inner = (void*)(orig & (~1));
33097         orig_conv.is_owned = false;
33098         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33099         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
33100         int64_t ret_ref = 0;
33101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33104         ret_ref = (uintptr_t)ret_var.inner;
33105         if (ret_var.is_owned) {
33106                 ret_ref |= 1;
33107         }
33108         return ret_ref;
33109 }
33110
33111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33112         if ((this_ptr & 1) != 0) return;
33113         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33114         CHECK_ACCESS(this_ptr_ptr);
33115         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
33116         FREE((void*)this_ptr);
33117         NetAddress_free(this_ptr_conv);
33118 }
33119
33120 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
33121         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33122         *ret_copy = NetAddress_clone(arg);
33123 int64_t ret_ref = (uintptr_t)ret_copy;
33124         return ret_ref;
33125 }
33126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33127         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
33128         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
33129         return ret_conv;
33130 }
33131
33132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33133         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
33134         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33135         *ret_copy = NetAddress_clone(orig_conv);
33136         int64_t ret_ref = (uintptr_t)ret_copy;
33137         return ret_ref;
33138 }
33139
33140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33141         LDKFourBytes addr_ref;
33142         CHECK((*env)->GetArrayLength(env, addr) == 4);
33143         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
33144         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33145         *ret_copy = NetAddress_ipv4(addr_ref, port);
33146         int64_t ret_ref = (uintptr_t)ret_copy;
33147         return ret_ref;
33148 }
33149
33150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33151         LDKSixteenBytes addr_ref;
33152         CHECK((*env)->GetArrayLength(env, addr) == 16);
33153         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
33154         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33155         *ret_copy = NetAddress_ipv6(addr_ref, port);
33156         int64_t ret_ref = (uintptr_t)ret_copy;
33157         return ret_ref;
33158 }
33159
33160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
33161         LDKTwelveBytes a_ref;
33162         CHECK((*env)->GetArrayLength(env, a) == 12);
33163         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
33164         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33165         *ret_copy = NetAddress_onion_v2(a_ref);
33166         int64_t ret_ref = (uintptr_t)ret_copy;
33167         return ret_ref;
33168 }
33169
33170 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) {
33171         LDKThirtyTwoBytes ed25519_pubkey_ref;
33172         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
33173         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
33174         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33175         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
33176         int64_t ret_ref = (uintptr_t)ret_copy;
33177         return ret_ref;
33178 }
33179
33180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
33181         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
33182         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
33183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33185         CVec_u8Z_free(ret_var);
33186         return ret_arr;
33187 }
33188
33189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33190         LDKu8slice ser_ref;
33191         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33192         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33193         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
33194         *ret_conv = NetAddress_read(ser_ref);
33195         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33196         return (int64_t)ret_conv;
33197 }
33198
33199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33200         LDKUnsignedNodeAnnouncement this_obj_conv;
33201         this_obj_conv.inner = (void*)(this_obj & (~1));
33202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33204         UnsignedNodeAnnouncement_free(this_obj_conv);
33205 }
33206
33207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33208         LDKUnsignedNodeAnnouncement this_ptr_conv;
33209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33210         this_ptr_conv.is_owned = false;
33211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33212         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
33213         int64_t ret_ref = 0;
33214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33217         ret_ref = (uintptr_t)ret_var.inner;
33218         if (ret_var.is_owned) {
33219                 ret_ref |= 1;
33220         }
33221         return ret_ref;
33222 }
33223
33224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33225         LDKUnsignedNodeAnnouncement this_ptr_conv;
33226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33227         this_ptr_conv.is_owned = false;
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33229         LDKNodeFeatures val_conv;
33230         val_conv.inner = (void*)(val & (~1));
33231         val_conv.is_owned = (val & 1) || (val == 0);
33232         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33233         val_conv = NodeFeatures_clone(&val_conv);
33234         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
33235 }
33236
33237 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33238         LDKUnsignedNodeAnnouncement this_ptr_conv;
33239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33240         this_ptr_conv.is_owned = false;
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33242         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
33243         return ret_conv;
33244 }
33245
33246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33247         LDKUnsignedNodeAnnouncement this_ptr_conv;
33248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33249         this_ptr_conv.is_owned = false;
33250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33251         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
33252 }
33253
33254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33255         LDKUnsignedNodeAnnouncement this_ptr_conv;
33256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33257         this_ptr_conv.is_owned = false;
33258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
33261         return ret_arr;
33262 }
33263
33264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33265         LDKUnsignedNodeAnnouncement this_ptr_conv;
33266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33267         this_ptr_conv.is_owned = false;
33268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33269         LDKPublicKey val_ref;
33270         CHECK((*env)->GetArrayLength(env, val) == 33);
33271         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33272         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
33273 }
33274
33275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
33276         LDKUnsignedNodeAnnouncement this_ptr_conv;
33277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33278         this_ptr_conv.is_owned = false;
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33280         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
33281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
33282         return ret_arr;
33283 }
33284
33285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33286         LDKUnsignedNodeAnnouncement this_ptr_conv;
33287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33288         this_ptr_conv.is_owned = false;
33289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33290         LDKThreeBytes val_ref;
33291         CHECK((*env)->GetArrayLength(env, val) == 3);
33292         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
33293         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
33294 }
33295
33296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33297         LDKUnsignedNodeAnnouncement this_ptr_conv;
33298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33299         this_ptr_conv.is_owned = false;
33300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
33303         return ret_arr;
33304 }
33305
33306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33307         LDKUnsignedNodeAnnouncement this_ptr_conv;
33308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33309         this_ptr_conv.is_owned = false;
33310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33311         LDKThirtyTwoBytes val_ref;
33312         CHECK((*env)->GetArrayLength(env, val) == 32);
33313         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33314         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
33315 }
33316
33317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33318         LDKUnsignedNodeAnnouncement this_ptr_conv;
33319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33320         this_ptr_conv.is_owned = false;
33321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33322         LDKCVec_NetAddressZ val_constr;
33323         val_constr.datalen = (*env)->GetArrayLength(env, val);
33324         if (val_constr.datalen > 0)
33325                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
33326         else
33327                 val_constr.data = NULL;
33328         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33329         for (size_t m = 0; m < val_constr.datalen; m++) {
33330                 int64_t val_conv_12 = val_vals[m];
33331                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
33332                 CHECK_ACCESS(val_conv_12_ptr);
33333                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
33334                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
33335                 val_constr.data[m] = val_conv_12_conv;
33336         }
33337         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33338         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
33339 }
33340
33341 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
33342         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
33343 int64_t ret_ref = 0;
33344 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33345 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33346 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33347 ret_ref = (uintptr_t)ret_var.inner;
33348 if (ret_var.is_owned) {
33349         ret_ref |= 1;
33350 }
33351         return ret_ref;
33352 }
33353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33354         LDKUnsignedNodeAnnouncement arg_conv;
33355         arg_conv.inner = (void*)(arg & (~1));
33356         arg_conv.is_owned = false;
33357         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33358         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
33359         return ret_conv;
33360 }
33361
33362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33363         LDKUnsignedNodeAnnouncement orig_conv;
33364         orig_conv.inner = (void*)(orig & (~1));
33365         orig_conv.is_owned = false;
33366         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33367         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
33368         int64_t ret_ref = 0;
33369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33372         ret_ref = (uintptr_t)ret_var.inner;
33373         if (ret_var.is_owned) {
33374                 ret_ref |= 1;
33375         }
33376         return ret_ref;
33377 }
33378
33379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33380         LDKNodeAnnouncement this_obj_conv;
33381         this_obj_conv.inner = (void*)(this_obj & (~1));
33382         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33384         NodeAnnouncement_free(this_obj_conv);
33385 }
33386
33387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33388         LDKNodeAnnouncement this_ptr_conv;
33389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33390         this_ptr_conv.is_owned = false;
33391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33392         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33393         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
33394         return ret_arr;
33395 }
33396
33397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33398         LDKNodeAnnouncement this_ptr_conv;
33399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33400         this_ptr_conv.is_owned = false;
33401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33402         LDKSignature val_ref;
33403         CHECK((*env)->GetArrayLength(env, val) == 64);
33404         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33405         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
33406 }
33407
33408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33409         LDKNodeAnnouncement this_ptr_conv;
33410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33411         this_ptr_conv.is_owned = false;
33412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33413         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
33414         int64_t ret_ref = 0;
33415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33418         ret_ref = (uintptr_t)ret_var.inner;
33419         if (ret_var.is_owned) {
33420                 ret_ref |= 1;
33421         }
33422         return ret_ref;
33423 }
33424
33425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33426         LDKNodeAnnouncement this_ptr_conv;
33427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33428         this_ptr_conv.is_owned = false;
33429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33430         LDKUnsignedNodeAnnouncement val_conv;
33431         val_conv.inner = (void*)(val & (~1));
33432         val_conv.is_owned = (val & 1) || (val == 0);
33433         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33434         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
33435         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
33436 }
33437
33438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
33439         LDKSignature signature_arg_ref;
33440         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33441         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33442         LDKUnsignedNodeAnnouncement contents_arg_conv;
33443         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33444         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33446         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
33447         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
33448         int64_t ret_ref = 0;
33449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33452         ret_ref = (uintptr_t)ret_var.inner;
33453         if (ret_var.is_owned) {
33454                 ret_ref |= 1;
33455         }
33456         return ret_ref;
33457 }
33458
33459 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
33460         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
33461 int64_t ret_ref = 0;
33462 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33463 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33464 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33465 ret_ref = (uintptr_t)ret_var.inner;
33466 if (ret_var.is_owned) {
33467         ret_ref |= 1;
33468 }
33469         return ret_ref;
33470 }
33471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33472         LDKNodeAnnouncement arg_conv;
33473         arg_conv.inner = (void*)(arg & (~1));
33474         arg_conv.is_owned = false;
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33476         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
33477         return ret_conv;
33478 }
33479
33480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33481         LDKNodeAnnouncement orig_conv;
33482         orig_conv.inner = (void*)(orig & (~1));
33483         orig_conv.is_owned = false;
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33485         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
33486         int64_t ret_ref = 0;
33487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33490         ret_ref = (uintptr_t)ret_var.inner;
33491         if (ret_var.is_owned) {
33492                 ret_ref |= 1;
33493         }
33494         return ret_ref;
33495 }
33496
33497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33498         LDKUnsignedChannelAnnouncement this_obj_conv;
33499         this_obj_conv.inner = (void*)(this_obj & (~1));
33500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33502         UnsignedChannelAnnouncement_free(this_obj_conv);
33503 }
33504
33505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33506         LDKUnsignedChannelAnnouncement this_ptr_conv;
33507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33508         this_ptr_conv.is_owned = false;
33509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33510         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
33511         int64_t ret_ref = 0;
33512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33515         ret_ref = (uintptr_t)ret_var.inner;
33516         if (ret_var.is_owned) {
33517                 ret_ref |= 1;
33518         }
33519         return ret_ref;
33520 }
33521
33522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33523         LDKUnsignedChannelAnnouncement this_ptr_conv;
33524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33525         this_ptr_conv.is_owned = false;
33526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33527         LDKChannelFeatures val_conv;
33528         val_conv.inner = (void*)(val & (~1));
33529         val_conv.is_owned = (val & 1) || (val == 0);
33530         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33531         val_conv = ChannelFeatures_clone(&val_conv);
33532         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
33533 }
33534
33535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33536         LDKUnsignedChannelAnnouncement this_ptr_conv;
33537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33538         this_ptr_conv.is_owned = false;
33539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33540         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
33542         return ret_arr;
33543 }
33544
33545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33546         LDKUnsignedChannelAnnouncement this_ptr_conv;
33547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33548         this_ptr_conv.is_owned = false;
33549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33550         LDKThirtyTwoBytes val_ref;
33551         CHECK((*env)->GetArrayLength(env, val) == 32);
33552         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33553         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
33554 }
33555
33556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33557         LDKUnsignedChannelAnnouncement this_ptr_conv;
33558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33559         this_ptr_conv.is_owned = false;
33560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33561         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
33562         return ret_conv;
33563 }
33564
33565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33566         LDKUnsignedChannelAnnouncement this_ptr_conv;
33567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33568         this_ptr_conv.is_owned = false;
33569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33570         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
33571 }
33572
33573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33574         LDKUnsignedChannelAnnouncement this_ptr_conv;
33575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33576         this_ptr_conv.is_owned = false;
33577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33578         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
33580         return ret_arr;
33581 }
33582
33583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33584         LDKUnsignedChannelAnnouncement this_ptr_conv;
33585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33586         this_ptr_conv.is_owned = false;
33587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33588         LDKPublicKey val_ref;
33589         CHECK((*env)->GetArrayLength(env, val) == 33);
33590         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33591         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
33592 }
33593
33594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33595         LDKUnsignedChannelAnnouncement this_ptr_conv;
33596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33597         this_ptr_conv.is_owned = false;
33598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33599         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33600         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
33601         return ret_arr;
33602 }
33603
33604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33605         LDKUnsignedChannelAnnouncement this_ptr_conv;
33606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33607         this_ptr_conv.is_owned = false;
33608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33609         LDKPublicKey val_ref;
33610         CHECK((*env)->GetArrayLength(env, val) == 33);
33611         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33612         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
33613 }
33614
33615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33616         LDKUnsignedChannelAnnouncement this_ptr_conv;
33617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33618         this_ptr_conv.is_owned = false;
33619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33620         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
33622         return ret_arr;
33623 }
33624
33625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33626         LDKUnsignedChannelAnnouncement this_ptr_conv;
33627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33628         this_ptr_conv.is_owned = false;
33629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33630         LDKPublicKey val_ref;
33631         CHECK((*env)->GetArrayLength(env, val) == 33);
33632         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33633         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
33634 }
33635
33636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33637         LDKUnsignedChannelAnnouncement this_ptr_conv;
33638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33639         this_ptr_conv.is_owned = false;
33640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33641         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
33643         return ret_arr;
33644 }
33645
33646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33647         LDKUnsignedChannelAnnouncement this_ptr_conv;
33648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33649         this_ptr_conv.is_owned = false;
33650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33651         LDKPublicKey val_ref;
33652         CHECK((*env)->GetArrayLength(env, val) == 33);
33653         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33654         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
33655 }
33656
33657 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
33658         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
33659 int64_t ret_ref = 0;
33660 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33661 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33662 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33663 ret_ref = (uintptr_t)ret_var.inner;
33664 if (ret_var.is_owned) {
33665         ret_ref |= 1;
33666 }
33667         return ret_ref;
33668 }
33669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33670         LDKUnsignedChannelAnnouncement arg_conv;
33671         arg_conv.inner = (void*)(arg & (~1));
33672         arg_conv.is_owned = false;
33673         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33674         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
33675         return ret_conv;
33676 }
33677
33678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33679         LDKUnsignedChannelAnnouncement orig_conv;
33680         orig_conv.inner = (void*)(orig & (~1));
33681         orig_conv.is_owned = false;
33682         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33683         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
33684         int64_t ret_ref = 0;
33685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33688         ret_ref = (uintptr_t)ret_var.inner;
33689         if (ret_var.is_owned) {
33690                 ret_ref |= 1;
33691         }
33692         return ret_ref;
33693 }
33694
33695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33696         LDKChannelAnnouncement this_obj_conv;
33697         this_obj_conv.inner = (void*)(this_obj & (~1));
33698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33700         ChannelAnnouncement_free(this_obj_conv);
33701 }
33702
33703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33704         LDKChannelAnnouncement this_ptr_conv;
33705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33706         this_ptr_conv.is_owned = false;
33707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33708         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
33710         return ret_arr;
33711 }
33712
33713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33714         LDKChannelAnnouncement this_ptr_conv;
33715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33716         this_ptr_conv.is_owned = false;
33717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33718         LDKSignature val_ref;
33719         CHECK((*env)->GetArrayLength(env, val) == 64);
33720         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33721         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
33722 }
33723
33724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33725         LDKChannelAnnouncement this_ptr_conv;
33726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33727         this_ptr_conv.is_owned = false;
33728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33729         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33730         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
33731         return ret_arr;
33732 }
33733
33734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33735         LDKChannelAnnouncement this_ptr_conv;
33736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33737         this_ptr_conv.is_owned = false;
33738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33739         LDKSignature val_ref;
33740         CHECK((*env)->GetArrayLength(env, val) == 64);
33741         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33742         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
33743 }
33744
33745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33746         LDKChannelAnnouncement this_ptr_conv;
33747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33748         this_ptr_conv.is_owned = false;
33749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33750         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33751         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
33752         return ret_arr;
33753 }
33754
33755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33756         LDKChannelAnnouncement this_ptr_conv;
33757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33758         this_ptr_conv.is_owned = false;
33759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33760         LDKSignature val_ref;
33761         CHECK((*env)->GetArrayLength(env, val) == 64);
33762         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33763         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
33764 }
33765
33766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33767         LDKChannelAnnouncement this_ptr_conv;
33768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33769         this_ptr_conv.is_owned = false;
33770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33771         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33772         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
33773         return ret_arr;
33774 }
33775
33776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33777         LDKChannelAnnouncement this_ptr_conv;
33778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33779         this_ptr_conv.is_owned = false;
33780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33781         LDKSignature val_ref;
33782         CHECK((*env)->GetArrayLength(env, val) == 64);
33783         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33784         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
33785 }
33786
33787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33788         LDKChannelAnnouncement this_ptr_conv;
33789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33790         this_ptr_conv.is_owned = false;
33791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33792         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
33793         int64_t ret_ref = 0;
33794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33797         ret_ref = (uintptr_t)ret_var.inner;
33798         if (ret_var.is_owned) {
33799                 ret_ref |= 1;
33800         }
33801         return ret_ref;
33802 }
33803
33804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33805         LDKChannelAnnouncement this_ptr_conv;
33806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33807         this_ptr_conv.is_owned = false;
33808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33809         LDKUnsignedChannelAnnouncement val_conv;
33810         val_conv.inner = (void*)(val & (~1));
33811         val_conv.is_owned = (val & 1) || (val == 0);
33812         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33813         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
33814         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
33815 }
33816
33817 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) {
33818         LDKSignature node_signature_1_arg_ref;
33819         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
33820         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
33821         LDKSignature node_signature_2_arg_ref;
33822         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
33823         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
33824         LDKSignature bitcoin_signature_1_arg_ref;
33825         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
33826         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
33827         LDKSignature bitcoin_signature_2_arg_ref;
33828         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
33829         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
33830         LDKUnsignedChannelAnnouncement contents_arg_conv;
33831         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33832         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33833         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33834         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
33835         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);
33836         int64_t ret_ref = 0;
33837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33840         ret_ref = (uintptr_t)ret_var.inner;
33841         if (ret_var.is_owned) {
33842                 ret_ref |= 1;
33843         }
33844         return ret_ref;
33845 }
33846
33847 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
33848         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
33849 int64_t ret_ref = 0;
33850 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33851 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33852 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33853 ret_ref = (uintptr_t)ret_var.inner;
33854 if (ret_var.is_owned) {
33855         ret_ref |= 1;
33856 }
33857         return ret_ref;
33858 }
33859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33860         LDKChannelAnnouncement arg_conv;
33861         arg_conv.inner = (void*)(arg & (~1));
33862         arg_conv.is_owned = false;
33863         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33864         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
33865         return ret_conv;
33866 }
33867
33868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33869         LDKChannelAnnouncement orig_conv;
33870         orig_conv.inner = (void*)(orig & (~1));
33871         orig_conv.is_owned = false;
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33873         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
33874         int64_t ret_ref = 0;
33875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33878         ret_ref = (uintptr_t)ret_var.inner;
33879         if (ret_var.is_owned) {
33880                 ret_ref |= 1;
33881         }
33882         return ret_ref;
33883 }
33884
33885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33886         LDKUnsignedChannelUpdate this_obj_conv;
33887         this_obj_conv.inner = (void*)(this_obj & (~1));
33888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33890         UnsignedChannelUpdate_free(this_obj_conv);
33891 }
33892
33893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33894         LDKUnsignedChannelUpdate this_ptr_conv;
33895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33896         this_ptr_conv.is_owned = false;
33897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33898         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
33900         return ret_arr;
33901 }
33902
33903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33904         LDKUnsignedChannelUpdate this_ptr_conv;
33905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33906         this_ptr_conv.is_owned = false;
33907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33908         LDKThirtyTwoBytes val_ref;
33909         CHECK((*env)->GetArrayLength(env, val) == 32);
33910         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33911         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
33912 }
33913
33914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33915         LDKUnsignedChannelUpdate this_ptr_conv;
33916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33917         this_ptr_conv.is_owned = false;
33918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33919         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
33920         return ret_conv;
33921 }
33922
33923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33924         LDKUnsignedChannelUpdate this_ptr_conv;
33925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33926         this_ptr_conv.is_owned = false;
33927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33928         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
33929 }
33930
33931 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33932         LDKUnsignedChannelUpdate this_ptr_conv;
33933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33934         this_ptr_conv.is_owned = false;
33935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33936         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
33937         return ret_conv;
33938 }
33939
33940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33941         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
33946 }
33947
33948 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33949         LDKUnsignedChannelUpdate this_ptr_conv;
33950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33951         this_ptr_conv.is_owned = false;
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33953         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
33954         return ret_conv;
33955 }
33956
33957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33958         LDKUnsignedChannelUpdate this_ptr_conv;
33959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33960         this_ptr_conv.is_owned = false;
33961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33962         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
33963 }
33964
33965 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
33966         LDKUnsignedChannelUpdate this_ptr_conv;
33967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33968         this_ptr_conv.is_owned = false;
33969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33970         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
33971         return ret_conv;
33972 }
33973
33974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33975         LDKUnsignedChannelUpdate this_ptr_conv;
33976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33977         this_ptr_conv.is_owned = false;
33978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33979         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
33980 }
33981
33982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33983         LDKUnsignedChannelUpdate this_ptr_conv;
33984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33985         this_ptr_conv.is_owned = false;
33986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33987         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
33988         return ret_conv;
33989 }
33990
33991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33992         LDKUnsignedChannelUpdate this_ptr_conv;
33993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33994         this_ptr_conv.is_owned = false;
33995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33996         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
33997 }
33998
33999 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34000         LDKUnsignedChannelUpdate this_ptr_conv;
34001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34002         this_ptr_conv.is_owned = false;
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34004         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
34005         return ret_conv;
34006 }
34007
34008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34009         LDKUnsignedChannelUpdate this_ptr_conv;
34010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34011         this_ptr_conv.is_owned = false;
34012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34013         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
34014 }
34015
34016 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
34017         LDKUnsignedChannelUpdate this_ptr_conv;
34018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34019         this_ptr_conv.is_owned = false;
34020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34021         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
34022         return ret_conv;
34023 }
34024
34025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34026         LDKUnsignedChannelUpdate this_ptr_conv;
34027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34028         this_ptr_conv.is_owned = false;
34029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34030         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
34031 }
34032
34033 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
34034         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
34035 int64_t ret_ref = 0;
34036 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34037 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34038 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34039 ret_ref = (uintptr_t)ret_var.inner;
34040 if (ret_var.is_owned) {
34041         ret_ref |= 1;
34042 }
34043         return ret_ref;
34044 }
34045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34046         LDKUnsignedChannelUpdate arg_conv;
34047         arg_conv.inner = (void*)(arg & (~1));
34048         arg_conv.is_owned = false;
34049         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34050         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
34051         return ret_conv;
34052 }
34053
34054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34055         LDKUnsignedChannelUpdate orig_conv;
34056         orig_conv.inner = (void*)(orig & (~1));
34057         orig_conv.is_owned = false;
34058         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34059         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
34060         int64_t ret_ref = 0;
34061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34064         ret_ref = (uintptr_t)ret_var.inner;
34065         if (ret_var.is_owned) {
34066                 ret_ref |= 1;
34067         }
34068         return ret_ref;
34069 }
34070
34071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34072         LDKChannelUpdate this_obj_conv;
34073         this_obj_conv.inner = (void*)(this_obj & (~1));
34074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34076         ChannelUpdate_free(this_obj_conv);
34077 }
34078
34079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34080         LDKChannelUpdate this_ptr_conv;
34081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34082         this_ptr_conv.is_owned = false;
34083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34084         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
34086         return ret_arr;
34087 }
34088
34089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34090         LDKChannelUpdate this_ptr_conv;
34091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34092         this_ptr_conv.is_owned = false;
34093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34094         LDKSignature val_ref;
34095         CHECK((*env)->GetArrayLength(env, val) == 64);
34096         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34097         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
34098 }
34099
34100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34101         LDKChannelUpdate this_ptr_conv;
34102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34103         this_ptr_conv.is_owned = false;
34104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34105         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
34106         int64_t ret_ref = 0;
34107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34110         ret_ref = (uintptr_t)ret_var.inner;
34111         if (ret_var.is_owned) {
34112                 ret_ref |= 1;
34113         }
34114         return ret_ref;
34115 }
34116
34117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34118         LDKChannelUpdate this_ptr_conv;
34119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34120         this_ptr_conv.is_owned = false;
34121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34122         LDKUnsignedChannelUpdate val_conv;
34123         val_conv.inner = (void*)(val & (~1));
34124         val_conv.is_owned = (val & 1) || (val == 0);
34125         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34126         val_conv = UnsignedChannelUpdate_clone(&val_conv);
34127         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
34128 }
34129
34130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34131         LDKSignature signature_arg_ref;
34132         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34133         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34134         LDKUnsignedChannelUpdate contents_arg_conv;
34135         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34136         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34137         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34138         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
34139         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
34140         int64_t ret_ref = 0;
34141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34144         ret_ref = (uintptr_t)ret_var.inner;
34145         if (ret_var.is_owned) {
34146                 ret_ref |= 1;
34147         }
34148         return ret_ref;
34149 }
34150
34151 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
34152         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
34153 int64_t ret_ref = 0;
34154 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34155 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34156 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34157 ret_ref = (uintptr_t)ret_var.inner;
34158 if (ret_var.is_owned) {
34159         ret_ref |= 1;
34160 }
34161         return ret_ref;
34162 }
34163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34164         LDKChannelUpdate arg_conv;
34165         arg_conv.inner = (void*)(arg & (~1));
34166         arg_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34168         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
34169         return ret_conv;
34170 }
34171
34172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34173         LDKChannelUpdate orig_conv;
34174         orig_conv.inner = (void*)(orig & (~1));
34175         orig_conv.is_owned = false;
34176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34177         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
34178         int64_t ret_ref = 0;
34179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34182         ret_ref = (uintptr_t)ret_var.inner;
34183         if (ret_var.is_owned) {
34184                 ret_ref |= 1;
34185         }
34186         return ret_ref;
34187 }
34188
34189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34190         LDKQueryChannelRange this_obj_conv;
34191         this_obj_conv.inner = (void*)(this_obj & (~1));
34192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34194         QueryChannelRange_free(this_obj_conv);
34195 }
34196
34197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34198         LDKQueryChannelRange this_ptr_conv;
34199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34200         this_ptr_conv.is_owned = false;
34201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34202         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
34204         return ret_arr;
34205 }
34206
34207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34208         LDKQueryChannelRange this_ptr_conv;
34209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34210         this_ptr_conv.is_owned = false;
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34212         LDKThirtyTwoBytes val_ref;
34213         CHECK((*env)->GetArrayLength(env, val) == 32);
34214         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34215         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34216 }
34217
34218 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34219         LDKQueryChannelRange this_ptr_conv;
34220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34221         this_ptr_conv.is_owned = false;
34222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34223         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
34224         return ret_conv;
34225 }
34226
34227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34228         LDKQueryChannelRange this_ptr_conv;
34229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34230         this_ptr_conv.is_owned = false;
34231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34232         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
34233 }
34234
34235 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34236         LDKQueryChannelRange this_ptr_conv;
34237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34238         this_ptr_conv.is_owned = false;
34239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34240         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
34241         return ret_conv;
34242 }
34243
34244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34245         LDKQueryChannelRange this_ptr_conv;
34246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34247         this_ptr_conv.is_owned = false;
34248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34249         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34250 }
34251
34252 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) {
34253         LDKThirtyTwoBytes chain_hash_arg_ref;
34254         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34255         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34256         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
34257         int64_t ret_ref = 0;
34258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34261         ret_ref = (uintptr_t)ret_var.inner;
34262         if (ret_var.is_owned) {
34263                 ret_ref |= 1;
34264         }
34265         return ret_ref;
34266 }
34267
34268 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
34269         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
34270 int64_t ret_ref = 0;
34271 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34272 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34273 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34274 ret_ref = (uintptr_t)ret_var.inner;
34275 if (ret_var.is_owned) {
34276         ret_ref |= 1;
34277 }
34278         return ret_ref;
34279 }
34280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34281         LDKQueryChannelRange arg_conv;
34282         arg_conv.inner = (void*)(arg & (~1));
34283         arg_conv.is_owned = false;
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34285         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
34286         return ret_conv;
34287 }
34288
34289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34290         LDKQueryChannelRange orig_conv;
34291         orig_conv.inner = (void*)(orig & (~1));
34292         orig_conv.is_owned = false;
34293         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34294         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
34295         int64_t ret_ref = 0;
34296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34299         ret_ref = (uintptr_t)ret_var.inner;
34300         if (ret_var.is_owned) {
34301                 ret_ref |= 1;
34302         }
34303         return ret_ref;
34304 }
34305
34306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34307         LDKReplyChannelRange this_obj_conv;
34308         this_obj_conv.inner = (void*)(this_obj & (~1));
34309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34311         ReplyChannelRange_free(this_obj_conv);
34312 }
34313
34314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34315         LDKReplyChannelRange this_ptr_conv;
34316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34317         this_ptr_conv.is_owned = false;
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34319         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
34321         return ret_arr;
34322 }
34323
34324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34325         LDKReplyChannelRange this_ptr_conv;
34326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34327         this_ptr_conv.is_owned = false;
34328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34329         LDKThirtyTwoBytes val_ref;
34330         CHECK((*env)->GetArrayLength(env, val) == 32);
34331         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34332         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34333 }
34334
34335 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34336         LDKReplyChannelRange this_ptr_conv;
34337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34338         this_ptr_conv.is_owned = false;
34339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34340         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
34341         return ret_conv;
34342 }
34343
34344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34345         LDKReplyChannelRange this_ptr_conv;
34346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34347         this_ptr_conv.is_owned = false;
34348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34349         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
34350 }
34351
34352 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34353         LDKReplyChannelRange this_ptr_conv;
34354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34355         this_ptr_conv.is_owned = false;
34356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34357         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
34358         return ret_conv;
34359 }
34360
34361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34362         LDKReplyChannelRange this_ptr_conv;
34363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34364         this_ptr_conv.is_owned = false;
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34366         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34367 }
34368
34369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
34370         LDKReplyChannelRange this_ptr_conv;
34371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34372         this_ptr_conv.is_owned = false;
34373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34374         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
34375         return ret_conv;
34376 }
34377
34378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34379         LDKReplyChannelRange this_ptr_conv;
34380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34381         this_ptr_conv.is_owned = false;
34382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34383         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
34384 }
34385
34386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34387         LDKReplyChannelRange this_ptr_conv;
34388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34389         this_ptr_conv.is_owned = false;
34390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34391         LDKCVec_u64Z val_constr;
34392         val_constr.datalen = (*env)->GetArrayLength(env, val);
34393         if (val_constr.datalen > 0)
34394                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34395         else
34396                 val_constr.data = NULL;
34397         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34398         for (size_t g = 0; g < val_constr.datalen; g++) {
34399                 int64_t val_conv_6 = val_vals[g];
34400                 val_constr.data[g] = val_conv_6;
34401         }
34402         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34403         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
34404 }
34405
34406 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) {
34407         LDKThirtyTwoBytes chain_hash_arg_ref;
34408         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34409         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34410         LDKCVec_u64Z short_channel_ids_arg_constr;
34411         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34412         if (short_channel_ids_arg_constr.datalen > 0)
34413                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34414         else
34415                 short_channel_ids_arg_constr.data = NULL;
34416         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34417         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34418                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34419                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34420         }
34421         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34422         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
34423         int64_t ret_ref = 0;
34424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34427         ret_ref = (uintptr_t)ret_var.inner;
34428         if (ret_var.is_owned) {
34429                 ret_ref |= 1;
34430         }
34431         return ret_ref;
34432 }
34433
34434 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
34435         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
34436 int64_t ret_ref = 0;
34437 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34438 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34439 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34440 ret_ref = (uintptr_t)ret_var.inner;
34441 if (ret_var.is_owned) {
34442         ret_ref |= 1;
34443 }
34444         return ret_ref;
34445 }
34446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34447         LDKReplyChannelRange arg_conv;
34448         arg_conv.inner = (void*)(arg & (~1));
34449         arg_conv.is_owned = false;
34450         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34451         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
34452         return ret_conv;
34453 }
34454
34455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34456         LDKReplyChannelRange orig_conv;
34457         orig_conv.inner = (void*)(orig & (~1));
34458         orig_conv.is_owned = false;
34459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34460         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
34461         int64_t ret_ref = 0;
34462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34465         ret_ref = (uintptr_t)ret_var.inner;
34466         if (ret_var.is_owned) {
34467                 ret_ref |= 1;
34468         }
34469         return ret_ref;
34470 }
34471
34472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34473         LDKQueryShortChannelIds this_obj_conv;
34474         this_obj_conv.inner = (void*)(this_obj & (~1));
34475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34477         QueryShortChannelIds_free(this_obj_conv);
34478 }
34479
34480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34481         LDKQueryShortChannelIds this_ptr_conv;
34482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34483         this_ptr_conv.is_owned = false;
34484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34485         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
34487         return ret_arr;
34488 }
34489
34490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34491         LDKQueryShortChannelIds this_ptr_conv;
34492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34493         this_ptr_conv.is_owned = false;
34494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34495         LDKThirtyTwoBytes val_ref;
34496         CHECK((*env)->GetArrayLength(env, val) == 32);
34497         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34498         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
34499 }
34500
34501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34502         LDKQueryShortChannelIds this_ptr_conv;
34503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34504         this_ptr_conv.is_owned = false;
34505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34506         LDKCVec_u64Z val_constr;
34507         val_constr.datalen = (*env)->GetArrayLength(env, val);
34508         if (val_constr.datalen > 0)
34509                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34510         else
34511                 val_constr.data = NULL;
34512         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34513         for (size_t g = 0; g < val_constr.datalen; g++) {
34514                 int64_t val_conv_6 = val_vals[g];
34515                 val_constr.data[g] = val_conv_6;
34516         }
34517         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34518         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
34519 }
34520
34521 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) {
34522         LDKThirtyTwoBytes chain_hash_arg_ref;
34523         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34524         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34525         LDKCVec_u64Z short_channel_ids_arg_constr;
34526         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34527         if (short_channel_ids_arg_constr.datalen > 0)
34528                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34529         else
34530                 short_channel_ids_arg_constr.data = NULL;
34531         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34532         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34533                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34534                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34535         }
34536         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34537         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
34538         int64_t ret_ref = 0;
34539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34542         ret_ref = (uintptr_t)ret_var.inner;
34543         if (ret_var.is_owned) {
34544                 ret_ref |= 1;
34545         }
34546         return ret_ref;
34547 }
34548
34549 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
34550         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
34551 int64_t ret_ref = 0;
34552 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34553 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34554 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34555 ret_ref = (uintptr_t)ret_var.inner;
34556 if (ret_var.is_owned) {
34557         ret_ref |= 1;
34558 }
34559         return ret_ref;
34560 }
34561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34562         LDKQueryShortChannelIds arg_conv;
34563         arg_conv.inner = (void*)(arg & (~1));
34564         arg_conv.is_owned = false;
34565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34566         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
34567         return ret_conv;
34568 }
34569
34570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34571         LDKQueryShortChannelIds orig_conv;
34572         orig_conv.inner = (void*)(orig & (~1));
34573         orig_conv.is_owned = false;
34574         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34575         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
34576         int64_t ret_ref = 0;
34577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34580         ret_ref = (uintptr_t)ret_var.inner;
34581         if (ret_var.is_owned) {
34582                 ret_ref |= 1;
34583         }
34584         return ret_ref;
34585 }
34586
34587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34588         LDKReplyShortChannelIdsEnd this_obj_conv;
34589         this_obj_conv.inner = (void*)(this_obj & (~1));
34590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34592         ReplyShortChannelIdsEnd_free(this_obj_conv);
34593 }
34594
34595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34596         LDKReplyShortChannelIdsEnd this_ptr_conv;
34597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34598         this_ptr_conv.is_owned = false;
34599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34600         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
34602         return ret_arr;
34603 }
34604
34605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34606         LDKReplyShortChannelIdsEnd this_ptr_conv;
34607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34608         this_ptr_conv.is_owned = false;
34609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34610         LDKThirtyTwoBytes val_ref;
34611         CHECK((*env)->GetArrayLength(env, val) == 32);
34612         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34613         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
34614 }
34615
34616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
34617         LDKReplyShortChannelIdsEnd this_ptr_conv;
34618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34619         this_ptr_conv.is_owned = false;
34620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34621         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
34622         return ret_conv;
34623 }
34624
34625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34626         LDKReplyShortChannelIdsEnd this_ptr_conv;
34627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34628         this_ptr_conv.is_owned = false;
34629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34630         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
34631 }
34632
34633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
34634         LDKThirtyTwoBytes chain_hash_arg_ref;
34635         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34636         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34637         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
34638         int64_t ret_ref = 0;
34639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34642         ret_ref = (uintptr_t)ret_var.inner;
34643         if (ret_var.is_owned) {
34644                 ret_ref |= 1;
34645         }
34646         return ret_ref;
34647 }
34648
34649 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
34650         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
34651 int64_t ret_ref = 0;
34652 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34653 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34654 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34655 ret_ref = (uintptr_t)ret_var.inner;
34656 if (ret_var.is_owned) {
34657         ret_ref |= 1;
34658 }
34659         return ret_ref;
34660 }
34661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34662         LDKReplyShortChannelIdsEnd arg_conv;
34663         arg_conv.inner = (void*)(arg & (~1));
34664         arg_conv.is_owned = false;
34665         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34666         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
34667         return ret_conv;
34668 }
34669
34670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34671         LDKReplyShortChannelIdsEnd orig_conv;
34672         orig_conv.inner = (void*)(orig & (~1));
34673         orig_conv.is_owned = false;
34674         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34675         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
34676         int64_t ret_ref = 0;
34677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34680         ret_ref = (uintptr_t)ret_var.inner;
34681         if (ret_var.is_owned) {
34682                 ret_ref |= 1;
34683         }
34684         return ret_ref;
34685 }
34686
34687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34688         LDKGossipTimestampFilter this_obj_conv;
34689         this_obj_conv.inner = (void*)(this_obj & (~1));
34690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34692         GossipTimestampFilter_free(this_obj_conv);
34693 }
34694
34695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34696         LDKGossipTimestampFilter this_ptr_conv;
34697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34698         this_ptr_conv.is_owned = false;
34699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34700         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
34702         return ret_arr;
34703 }
34704
34705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34706         LDKGossipTimestampFilter this_ptr_conv;
34707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34708         this_ptr_conv.is_owned = false;
34709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34710         LDKThirtyTwoBytes val_ref;
34711         CHECK((*env)->GetArrayLength(env, val) == 32);
34712         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34713         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
34714 }
34715
34716 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34717         LDKGossipTimestampFilter this_ptr_conv;
34718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34719         this_ptr_conv.is_owned = false;
34720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34721         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
34722         return ret_conv;
34723 }
34724
34725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34726         LDKGossipTimestampFilter this_ptr_conv;
34727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34728         this_ptr_conv.is_owned = false;
34729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34730         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
34731 }
34732
34733 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34734         LDKGossipTimestampFilter this_ptr_conv;
34735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34736         this_ptr_conv.is_owned = false;
34737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34738         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
34739         return ret_conv;
34740 }
34741
34742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34743         LDKGossipTimestampFilter this_ptr_conv;
34744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34745         this_ptr_conv.is_owned = false;
34746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34747         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
34748 }
34749
34750 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) {
34751         LDKThirtyTwoBytes chain_hash_arg_ref;
34752         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34753         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34754         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
34755         int64_t ret_ref = 0;
34756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34759         ret_ref = (uintptr_t)ret_var.inner;
34760         if (ret_var.is_owned) {
34761                 ret_ref |= 1;
34762         }
34763         return ret_ref;
34764 }
34765
34766 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
34767         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
34768 int64_t ret_ref = 0;
34769 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34770 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34771 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34772 ret_ref = (uintptr_t)ret_var.inner;
34773 if (ret_var.is_owned) {
34774         ret_ref |= 1;
34775 }
34776         return ret_ref;
34777 }
34778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34779         LDKGossipTimestampFilter arg_conv;
34780         arg_conv.inner = (void*)(arg & (~1));
34781         arg_conv.is_owned = false;
34782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34783         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
34784         return ret_conv;
34785 }
34786
34787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34788         LDKGossipTimestampFilter orig_conv;
34789         orig_conv.inner = (void*)(orig & (~1));
34790         orig_conv.is_owned = false;
34791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34792         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
34793         int64_t ret_ref = 0;
34794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34797         ret_ref = (uintptr_t)ret_var.inner;
34798         if (ret_var.is_owned) {
34799                 ret_ref |= 1;
34800         }
34801         return ret_ref;
34802 }
34803
34804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34805         if ((this_ptr & 1) != 0) return;
34806         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34807         CHECK_ACCESS(this_ptr_ptr);
34808         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
34809         FREE((void*)this_ptr);
34810         ErrorAction_free(this_ptr_conv);
34811 }
34812
34813 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
34814         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34815         *ret_copy = ErrorAction_clone(arg);
34816 int64_t ret_ref = (uintptr_t)ret_copy;
34817         return ret_ref;
34818 }
34819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34820         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
34821         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
34822         return ret_conv;
34823 }
34824
34825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34826         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
34827         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34828         *ret_copy = ErrorAction_clone(orig_conv);
34829         int64_t ret_ref = (uintptr_t)ret_copy;
34830         return ret_ref;
34831 }
34832
34833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
34834         LDKErrorMessage msg_conv;
34835         msg_conv.inner = (void*)(msg & (~1));
34836         msg_conv.is_owned = (msg & 1) || (msg == 0);
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34838         msg_conv = ErrorMessage_clone(&msg_conv);
34839         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34840         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
34841         int64_t ret_ref = (uintptr_t)ret_copy;
34842         return ret_ref;
34843 }
34844
34845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
34846         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34847         *ret_copy = ErrorAction_ignore_error();
34848         int64_t ret_ref = (uintptr_t)ret_copy;
34849         return ret_ref;
34850 }
34851
34852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
34853         LDKLevel a_conv = LDKLevel_from_java(env, a);
34854         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34855         *ret_copy = ErrorAction_ignore_and_log(a_conv);
34856         int64_t ret_ref = (uintptr_t)ret_copy;
34857         return ret_ref;
34858 }
34859
34860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
34861         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34862         *ret_copy = ErrorAction_ignore_duplicate_gossip();
34863         int64_t ret_ref = (uintptr_t)ret_copy;
34864         return ret_ref;
34865 }
34866
34867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
34868         LDKErrorMessage msg_conv;
34869         msg_conv.inner = (void*)(msg & (~1));
34870         msg_conv.is_owned = (msg & 1) || (msg == 0);
34871         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34872         msg_conv = ErrorMessage_clone(&msg_conv);
34873         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34874         *ret_copy = ErrorAction_send_error_message(msg_conv);
34875         int64_t ret_ref = (uintptr_t)ret_copy;
34876         return ret_ref;
34877 }
34878
34879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
34880         LDKWarningMessage msg_conv;
34881         msg_conv.inner = (void*)(msg & (~1));
34882         msg_conv.is_owned = (msg & 1) || (msg == 0);
34883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34884         msg_conv = WarningMessage_clone(&msg_conv);
34885         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
34886         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34887         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
34888         int64_t ret_ref = (uintptr_t)ret_copy;
34889         return ret_ref;
34890 }
34891
34892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34893         LDKLightningError this_obj_conv;
34894         this_obj_conv.inner = (void*)(this_obj & (~1));
34895         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34897         LightningError_free(this_obj_conv);
34898 }
34899
34900 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
34901         LDKLightningError this_ptr_conv;
34902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34903         this_ptr_conv.is_owned = false;
34904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34905         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
34906         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34907         Str_free(ret_str);
34908         return ret_conv;
34909 }
34910
34911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34912         LDKLightningError this_ptr_conv;
34913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34914         this_ptr_conv.is_owned = false;
34915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34916         LDKStr val_conv = java_to_owned_str(env, val);
34917         LightningError_set_err(&this_ptr_conv, val_conv);
34918 }
34919
34920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
34921         LDKLightningError this_ptr_conv;
34922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34923         this_ptr_conv.is_owned = false;
34924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34925         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34926         *ret_copy = LightningError_get_action(&this_ptr_conv);
34927         int64_t ret_ref = (uintptr_t)ret_copy;
34928         return ret_ref;
34929 }
34930
34931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34932         LDKLightningError this_ptr_conv;
34933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34934         this_ptr_conv.is_owned = false;
34935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34936         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34937         CHECK_ACCESS(val_ptr);
34938         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
34939         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
34940         LightningError_set_action(&this_ptr_conv, val_conv);
34941 }
34942
34943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
34944         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
34945         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
34946         CHECK_ACCESS(action_arg_ptr);
34947         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
34948         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
34949         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
34950         int64_t ret_ref = 0;
34951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34954         ret_ref = (uintptr_t)ret_var.inner;
34955         if (ret_var.is_owned) {
34956                 ret_ref |= 1;
34957         }
34958         return ret_ref;
34959 }
34960
34961 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
34962         LDKLightningError ret_var = LightningError_clone(arg);
34963 int64_t ret_ref = 0;
34964 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34965 CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
34968 if (ret_var.is_owned) {
34969         ret_ref |= 1;
34970 }
34971         return ret_ref;
34972 }
34973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34974         LDKLightningError arg_conv;
34975         arg_conv.inner = (void*)(arg & (~1));
34976         arg_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34978         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
34979         return ret_conv;
34980 }
34981
34982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34983         LDKLightningError orig_conv;
34984         orig_conv.inner = (void*)(orig & (~1));
34985         orig_conv.is_owned = false;
34986         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34987         LDKLightningError ret_var = LightningError_clone(&orig_conv);
34988         int64_t ret_ref = 0;
34989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34992         ret_ref = (uintptr_t)ret_var.inner;
34993         if (ret_var.is_owned) {
34994                 ret_ref |= 1;
34995         }
34996         return ret_ref;
34997 }
34998
34999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35000         LDKCommitmentUpdate this_obj_conv;
35001         this_obj_conv.inner = (void*)(this_obj & (~1));
35002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35004         CommitmentUpdate_free(this_obj_conv);
35005 }
35006
35007 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35008         LDKCommitmentUpdate this_ptr_conv;
35009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35010         this_ptr_conv.is_owned = false;
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35012         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
35013         int64_tArray ret_arr = NULL;
35014         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35015         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35016         for (size_t p = 0; p < ret_var.datalen; p++) {
35017                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
35018                 int64_t ret_conv_15_ref = 0;
35019                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35020                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35021                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
35022                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
35023                 if (ret_conv_15_var.is_owned) {
35024                         ret_conv_15_ref |= 1;
35025                 }
35026                 ret_arr_ptr[p] = ret_conv_15_ref;
35027         }
35028         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35029         FREE(ret_var.data);
35030         return ret_arr;
35031 }
35032
35033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35034         LDKCommitmentUpdate this_ptr_conv;
35035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35036         this_ptr_conv.is_owned = false;
35037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35038         LDKCVec_UpdateAddHTLCZ val_constr;
35039         val_constr.datalen = (*env)->GetArrayLength(env, val);
35040         if (val_constr.datalen > 0)
35041                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35042         else
35043                 val_constr.data = NULL;
35044         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35045         for (size_t p = 0; p < val_constr.datalen; p++) {
35046                 int64_t val_conv_15 = val_vals[p];
35047                 LDKUpdateAddHTLC val_conv_15_conv;
35048                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
35049                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
35050                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
35051                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
35052                 val_constr.data[p] = val_conv_15_conv;
35053         }
35054         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35055         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
35056 }
35057
35058 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35059         LDKCommitmentUpdate this_ptr_conv;
35060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35061         this_ptr_conv.is_owned = false;
35062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35063         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
35064         int64_tArray ret_arr = NULL;
35065         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35066         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35067         for (size_t t = 0; t < ret_var.datalen; t++) {
35068                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
35069                 int64_t ret_conv_19_ref = 0;
35070                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35071                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35072                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
35073                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
35074                 if (ret_conv_19_var.is_owned) {
35075                         ret_conv_19_ref |= 1;
35076                 }
35077                 ret_arr_ptr[t] = ret_conv_19_ref;
35078         }
35079         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35080         FREE(ret_var.data);
35081         return ret_arr;
35082 }
35083
35084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35085         LDKCommitmentUpdate this_ptr_conv;
35086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35087         this_ptr_conv.is_owned = false;
35088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35089         LDKCVec_UpdateFulfillHTLCZ val_constr;
35090         val_constr.datalen = (*env)->GetArrayLength(env, val);
35091         if (val_constr.datalen > 0)
35092                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35093         else
35094                 val_constr.data = NULL;
35095         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35096         for (size_t t = 0; t < val_constr.datalen; t++) {
35097                 int64_t val_conv_19 = val_vals[t];
35098                 LDKUpdateFulfillHTLC val_conv_19_conv;
35099                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
35100                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
35101                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
35102                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
35103                 val_constr.data[t] = val_conv_19_conv;
35104         }
35105         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35106         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
35107 }
35108
35109 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35110         LDKCommitmentUpdate this_ptr_conv;
35111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35112         this_ptr_conv.is_owned = false;
35113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35114         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
35115         int64_tArray ret_arr = NULL;
35116         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35117         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35118         for (size_t q = 0; q < ret_var.datalen; q++) {
35119                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
35120                 int64_t ret_conv_16_ref = 0;
35121                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35122                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35123                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35124                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
35125                 if (ret_conv_16_var.is_owned) {
35126                         ret_conv_16_ref |= 1;
35127                 }
35128                 ret_arr_ptr[q] = ret_conv_16_ref;
35129         }
35130         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35131         FREE(ret_var.data);
35132         return ret_arr;
35133 }
35134
35135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35136         LDKCommitmentUpdate this_ptr_conv;
35137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35138         this_ptr_conv.is_owned = false;
35139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35140         LDKCVec_UpdateFailHTLCZ val_constr;
35141         val_constr.datalen = (*env)->GetArrayLength(env, val);
35142         if (val_constr.datalen > 0)
35143                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35144         else
35145                 val_constr.data = NULL;
35146         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35147         for (size_t q = 0; q < val_constr.datalen; q++) {
35148                 int64_t val_conv_16 = val_vals[q];
35149                 LDKUpdateFailHTLC val_conv_16_conv;
35150                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
35151                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
35152                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
35153                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
35154                 val_constr.data[q] = val_conv_16_conv;
35155         }
35156         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35157         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
35158 }
35159
35160 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35161         LDKCommitmentUpdate this_ptr_conv;
35162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35163         this_ptr_conv.is_owned = false;
35164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35165         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
35166         int64_tArray ret_arr = NULL;
35167         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35168         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35169         for (size_t z = 0; z < ret_var.datalen; z++) {
35170                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
35171                 int64_t ret_conv_25_ref = 0;
35172                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35173                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
35175                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
35176                 if (ret_conv_25_var.is_owned) {
35177                         ret_conv_25_ref |= 1;
35178                 }
35179                 ret_arr_ptr[z] = ret_conv_25_ref;
35180         }
35181         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35182         FREE(ret_var.data);
35183         return ret_arr;
35184 }
35185
35186 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) {
35187         LDKCommitmentUpdate this_ptr_conv;
35188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35189         this_ptr_conv.is_owned = false;
35190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35191         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
35192         val_constr.datalen = (*env)->GetArrayLength(env, val);
35193         if (val_constr.datalen > 0)
35194                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35195         else
35196                 val_constr.data = NULL;
35197         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35198         for (size_t z = 0; z < val_constr.datalen; z++) {
35199                 int64_t val_conv_25 = val_vals[z];
35200                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
35201                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
35202                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
35203                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
35204                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
35205                 val_constr.data[z] = val_conv_25_conv;
35206         }
35207         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35208         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
35209 }
35210
35211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
35212         LDKCommitmentUpdate this_ptr_conv;
35213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35214         this_ptr_conv.is_owned = false;
35215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35216         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
35217         int64_t ret_ref = 0;
35218         if ((uintptr_t)ret_var.inner > 4096) {
35219                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35220                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35222                 ret_ref = (uintptr_t)ret_var.inner;
35223                 if (ret_var.is_owned) {
35224                         ret_ref |= 1;
35225                 }
35226         }
35227         return ret_ref;
35228 }
35229
35230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35231         LDKCommitmentUpdate this_ptr_conv;
35232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35233         this_ptr_conv.is_owned = false;
35234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35235         LDKUpdateFee val_conv;
35236         val_conv.inner = (void*)(val & (~1));
35237         val_conv.is_owned = (val & 1) || (val == 0);
35238         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35239         val_conv = UpdateFee_clone(&val_conv);
35240         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
35241 }
35242
35243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
35244         LDKCommitmentUpdate this_ptr_conv;
35245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35246         this_ptr_conv.is_owned = false;
35247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35248         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
35249         int64_t ret_ref = 0;
35250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35253         ret_ref = (uintptr_t)ret_var.inner;
35254         if (ret_var.is_owned) {
35255                 ret_ref |= 1;
35256         }
35257         return ret_ref;
35258 }
35259
35260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35261         LDKCommitmentUpdate this_ptr_conv;
35262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35263         this_ptr_conv.is_owned = false;
35264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35265         LDKCommitmentSigned val_conv;
35266         val_conv.inner = (void*)(val & (~1));
35267         val_conv.is_owned = (val & 1) || (val == 0);
35268         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35269         val_conv = CommitmentSigned_clone(&val_conv);
35270         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
35271 }
35272
35273 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) {
35274         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
35275         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
35276         if (update_add_htlcs_arg_constr.datalen > 0)
35277                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35278         else
35279                 update_add_htlcs_arg_constr.data = NULL;
35280         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
35281         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
35282                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
35283                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
35284                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
35285                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
35286                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
35287                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
35288                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
35289         }
35290         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
35291         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
35292         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
35293         if (update_fulfill_htlcs_arg_constr.datalen > 0)
35294                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35295         else
35296                 update_fulfill_htlcs_arg_constr.data = NULL;
35297         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
35298         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
35299                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
35300                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
35301                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
35302                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
35303                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
35304                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
35305                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
35306         }
35307         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
35308         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
35309         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
35310         if (update_fail_htlcs_arg_constr.datalen > 0)
35311                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35312         else
35313                 update_fail_htlcs_arg_constr.data = NULL;
35314         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
35315         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
35316                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
35317                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
35318                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
35319                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
35320                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
35321                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
35322                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
35323         }
35324         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
35325         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
35326         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
35327         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
35328                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35329         else
35330                 update_fail_malformed_htlcs_arg_constr.data = NULL;
35331         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
35332         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
35333                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
35334                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
35335                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
35336                 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);
35337                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
35338                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
35339                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
35340         }
35341         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
35342         LDKUpdateFee update_fee_arg_conv;
35343         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
35344         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
35345         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
35346         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
35347         LDKCommitmentSigned commitment_signed_arg_conv;
35348         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
35349         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
35350         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
35351         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
35352         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);
35353         int64_t ret_ref = 0;
35354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35357         ret_ref = (uintptr_t)ret_var.inner;
35358         if (ret_var.is_owned) {
35359                 ret_ref |= 1;
35360         }
35361         return ret_ref;
35362 }
35363
35364 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
35365         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
35366 int64_t ret_ref = 0;
35367 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35368 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35369 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35370 ret_ref = (uintptr_t)ret_var.inner;
35371 if (ret_var.is_owned) {
35372         ret_ref |= 1;
35373 }
35374         return ret_ref;
35375 }
35376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35377         LDKCommitmentUpdate arg_conv;
35378         arg_conv.inner = (void*)(arg & (~1));
35379         arg_conv.is_owned = false;
35380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35381         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
35382         return ret_conv;
35383 }
35384
35385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35386         LDKCommitmentUpdate orig_conv;
35387         orig_conv.inner = (void*)(orig & (~1));
35388         orig_conv.is_owned = false;
35389         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35390         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
35391         int64_t ret_ref = 0;
35392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35395         ret_ref = (uintptr_t)ret_var.inner;
35396         if (ret_var.is_owned) {
35397                 ret_ref |= 1;
35398         }
35399         return ret_ref;
35400 }
35401
35402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35403         if ((this_ptr & 1) != 0) return;
35404         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35405         CHECK_ACCESS(this_ptr_ptr);
35406         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
35407         FREE((void*)this_ptr);
35408         ChannelMessageHandler_free(this_ptr_conv);
35409 }
35410
35411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35412         if ((this_ptr & 1) != 0) return;
35413         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35414         CHECK_ACCESS(this_ptr_ptr);
35415         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
35416         FREE((void*)this_ptr);
35417         RoutingMessageHandler_free(this_ptr_conv);
35418 }
35419
35420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35421         LDKAcceptChannel obj_conv;
35422         obj_conv.inner = (void*)(obj & (~1));
35423         obj_conv.is_owned = false;
35424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35425         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
35426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35428         CVec_u8Z_free(ret_var);
35429         return ret_arr;
35430 }
35431
35432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35433         LDKu8slice ser_ref;
35434         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35435         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35436         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
35437         *ret_conv = AcceptChannel_read(ser_ref);
35438         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35439         return (int64_t)ret_conv;
35440 }
35441
35442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35443         LDKAnnouncementSignatures obj_conv;
35444         obj_conv.inner = (void*)(obj & (~1));
35445         obj_conv.is_owned = false;
35446         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35447         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
35448         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35449         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35450         CVec_u8Z_free(ret_var);
35451         return ret_arr;
35452 }
35453
35454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35455         LDKu8slice ser_ref;
35456         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35457         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35458         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
35459         *ret_conv = AnnouncementSignatures_read(ser_ref);
35460         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35461         return (int64_t)ret_conv;
35462 }
35463
35464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
35465         LDKChannelReestablish obj_conv;
35466         obj_conv.inner = (void*)(obj & (~1));
35467         obj_conv.is_owned = false;
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35469         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
35470         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35471         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35472         CVec_u8Z_free(ret_var);
35473         return ret_arr;
35474 }
35475
35476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35477         LDKu8slice ser_ref;
35478         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35479         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35480         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
35481         *ret_conv = ChannelReestablish_read(ser_ref);
35482         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35483         return (int64_t)ret_conv;
35484 }
35485
35486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35487         LDKClosingSigned obj_conv;
35488         obj_conv.inner = (void*)(obj & (~1));
35489         obj_conv.is_owned = false;
35490         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35491         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
35492         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35493         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35494         CVec_u8Z_free(ret_var);
35495         return ret_arr;
35496 }
35497
35498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35499         LDKu8slice ser_ref;
35500         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35501         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35502         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
35503         *ret_conv = ClosingSigned_read(ser_ref);
35504         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35505         return (int64_t)ret_conv;
35506 }
35507
35508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35509         LDKClosingSignedFeeRange obj_conv;
35510         obj_conv.inner = (void*)(obj & (~1));
35511         obj_conv.is_owned = false;
35512         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35513         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
35514         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35515         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35516         CVec_u8Z_free(ret_var);
35517         return ret_arr;
35518 }
35519
35520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35521         LDKu8slice ser_ref;
35522         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35523         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35524         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
35525         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
35526         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35527         return (int64_t)ret_conv;
35528 }
35529
35530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35531         LDKCommitmentSigned obj_conv;
35532         obj_conv.inner = (void*)(obj & (~1));
35533         obj_conv.is_owned = false;
35534         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35535         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
35536         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35537         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35538         CVec_u8Z_free(ret_var);
35539         return ret_arr;
35540 }
35541
35542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35543         LDKu8slice ser_ref;
35544         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35545         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35546         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
35547         *ret_conv = CommitmentSigned_read(ser_ref);
35548         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35549         return (int64_t)ret_conv;
35550 }
35551
35552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
35553         LDKFundingCreated obj_conv;
35554         obj_conv.inner = (void*)(obj & (~1));
35555         obj_conv.is_owned = false;
35556         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35557         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
35558         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35559         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35560         CVec_u8Z_free(ret_var);
35561         return ret_arr;
35562 }
35563
35564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35565         LDKu8slice ser_ref;
35566         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35567         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35568         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
35569         *ret_conv = FundingCreated_read(ser_ref);
35570         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35571         return (int64_t)ret_conv;
35572 }
35573
35574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35575         LDKFundingSigned obj_conv;
35576         obj_conv.inner = (void*)(obj & (~1));
35577         obj_conv.is_owned = false;
35578         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35579         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
35580         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35581         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35582         CVec_u8Z_free(ret_var);
35583         return ret_arr;
35584 }
35585
35586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35587         LDKu8slice ser_ref;
35588         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35589         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35590         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
35591         *ret_conv = FundingSigned_read(ser_ref);
35592         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35593         return (int64_t)ret_conv;
35594 }
35595
35596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
35597         LDKFundingLocked obj_conv;
35598         obj_conv.inner = (void*)(obj & (~1));
35599         obj_conv.is_owned = false;
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35601         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
35602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35604         CVec_u8Z_free(ret_var);
35605         return ret_arr;
35606 }
35607
35608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35609         LDKu8slice ser_ref;
35610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35612         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
35613         *ret_conv = FundingLocked_read(ser_ref);
35614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35615         return (int64_t)ret_conv;
35616 }
35617
35618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
35619         LDKInit obj_conv;
35620         obj_conv.inner = (void*)(obj & (~1));
35621         obj_conv.is_owned = false;
35622         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35623         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
35624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35626         CVec_u8Z_free(ret_var);
35627         return ret_arr;
35628 }
35629
35630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35631         LDKu8slice ser_ref;
35632         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35633         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35634         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
35635         *ret_conv = Init_read(ser_ref);
35636         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35637         return (int64_t)ret_conv;
35638 }
35639
35640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35641         LDKOpenChannel obj_conv;
35642         obj_conv.inner = (void*)(obj & (~1));
35643         obj_conv.is_owned = false;
35644         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35645         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
35646         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35647         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35648         CVec_u8Z_free(ret_var);
35649         return ret_arr;
35650 }
35651
35652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35653         LDKu8slice ser_ref;
35654         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35655         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35656         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
35657         *ret_conv = OpenChannel_read(ser_ref);
35658         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35659         return (int64_t)ret_conv;
35660 }
35661
35662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
35663         LDKRevokeAndACK obj_conv;
35664         obj_conv.inner = (void*)(obj & (~1));
35665         obj_conv.is_owned = false;
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35667         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
35668         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35669         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35670         CVec_u8Z_free(ret_var);
35671         return ret_arr;
35672 }
35673
35674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35675         LDKu8slice ser_ref;
35676         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35677         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35678         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
35679         *ret_conv = RevokeAndACK_read(ser_ref);
35680         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35681         return (int64_t)ret_conv;
35682 }
35683
35684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
35685         LDKShutdown obj_conv;
35686         obj_conv.inner = (void*)(obj & (~1));
35687         obj_conv.is_owned = false;
35688         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35689         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
35690         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35691         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35692         CVec_u8Z_free(ret_var);
35693         return ret_arr;
35694 }
35695
35696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35697         LDKu8slice ser_ref;
35698         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35699         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35700         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
35701         *ret_conv = Shutdown_read(ser_ref);
35702         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35703         return (int64_t)ret_conv;
35704 }
35705
35706 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35707         LDKUpdateFailHTLC obj_conv;
35708         obj_conv.inner = (void*)(obj & (~1));
35709         obj_conv.is_owned = false;
35710         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35711         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
35712         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35713         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35714         CVec_u8Z_free(ret_var);
35715         return ret_arr;
35716 }
35717
35718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35719         LDKu8slice ser_ref;
35720         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35721         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35722         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
35723         *ret_conv = UpdateFailHTLC_read(ser_ref);
35724         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35725         return (int64_t)ret_conv;
35726 }
35727
35728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35729         LDKUpdateFailMalformedHTLC obj_conv;
35730         obj_conv.inner = (void*)(obj & (~1));
35731         obj_conv.is_owned = false;
35732         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35733         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
35734         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35735         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35736         CVec_u8Z_free(ret_var);
35737         return ret_arr;
35738 }
35739
35740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35741         LDKu8slice ser_ref;
35742         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35743         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35744         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
35745         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
35746         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35747         return (int64_t)ret_conv;
35748 }
35749
35750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
35751         LDKUpdateFee obj_conv;
35752         obj_conv.inner = (void*)(obj & (~1));
35753         obj_conv.is_owned = false;
35754         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35755         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
35756         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35757         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35758         CVec_u8Z_free(ret_var);
35759         return ret_arr;
35760 }
35761
35762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35763         LDKu8slice ser_ref;
35764         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35765         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35766         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
35767         *ret_conv = UpdateFee_read(ser_ref);
35768         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35769         return (int64_t)ret_conv;
35770 }
35771
35772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35773         LDKUpdateFulfillHTLC obj_conv;
35774         obj_conv.inner = (void*)(obj & (~1));
35775         obj_conv.is_owned = false;
35776         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35777         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
35778         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35779         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35780         CVec_u8Z_free(ret_var);
35781         return ret_arr;
35782 }
35783
35784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35785         LDKu8slice ser_ref;
35786         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35787         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35788         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
35789         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
35790         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35791         return (int64_t)ret_conv;
35792 }
35793
35794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35795         LDKUpdateAddHTLC obj_conv;
35796         obj_conv.inner = (void*)(obj & (~1));
35797         obj_conv.is_owned = false;
35798         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35799         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
35800         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35801         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35802         CVec_u8Z_free(ret_var);
35803         return ret_arr;
35804 }
35805
35806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35807         LDKu8slice ser_ref;
35808         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35809         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35810         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
35811         *ret_conv = UpdateAddHTLC_read(ser_ref);
35812         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35813         return (int64_t)ret_conv;
35814 }
35815
35816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
35817         LDKPing obj_conv;
35818         obj_conv.inner = (void*)(obj & (~1));
35819         obj_conv.is_owned = false;
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35821         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
35822         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35823         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35824         CVec_u8Z_free(ret_var);
35825         return ret_arr;
35826 }
35827
35828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35829         LDKu8slice ser_ref;
35830         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35831         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35832         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
35833         *ret_conv = Ping_read(ser_ref);
35834         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35835         return (int64_t)ret_conv;
35836 }
35837
35838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
35839         LDKPong obj_conv;
35840         obj_conv.inner = (void*)(obj & (~1));
35841         obj_conv.is_owned = false;
35842         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35843         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
35844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35846         CVec_u8Z_free(ret_var);
35847         return ret_arr;
35848 }
35849
35850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35851         LDKu8slice ser_ref;
35852         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35853         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35854         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
35855         *ret_conv = Pong_read(ser_ref);
35856         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35857         return (int64_t)ret_conv;
35858 }
35859
35860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35861         LDKUnsignedChannelAnnouncement obj_conv;
35862         obj_conv.inner = (void*)(obj & (~1));
35863         obj_conv.is_owned = false;
35864         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35865         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
35866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35868         CVec_u8Z_free(ret_var);
35869         return ret_arr;
35870 }
35871
35872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35873         LDKu8slice ser_ref;
35874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35876         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
35877         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
35878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35879         return (int64_t)ret_conv;
35880 }
35881
35882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35883         LDKChannelAnnouncement obj_conv;
35884         obj_conv.inner = (void*)(obj & (~1));
35885         obj_conv.is_owned = false;
35886         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35887         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
35888         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35889         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35890         CVec_u8Z_free(ret_var);
35891         return ret_arr;
35892 }
35893
35894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35895         LDKu8slice ser_ref;
35896         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35897         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35898         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
35899         *ret_conv = ChannelAnnouncement_read(ser_ref);
35900         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35901         return (int64_t)ret_conv;
35902 }
35903
35904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35905         LDKUnsignedChannelUpdate obj_conv;
35906         obj_conv.inner = (void*)(obj & (~1));
35907         obj_conv.is_owned = false;
35908         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35909         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
35910         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35911         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35912         CVec_u8Z_free(ret_var);
35913         return ret_arr;
35914 }
35915
35916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35917         LDKu8slice ser_ref;
35918         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35919         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35920         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
35921         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
35922         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35923         return (int64_t)ret_conv;
35924 }
35925
35926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35927         LDKChannelUpdate obj_conv;
35928         obj_conv.inner = (void*)(obj & (~1));
35929         obj_conv.is_owned = false;
35930         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35931         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
35932         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35933         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35934         CVec_u8Z_free(ret_var);
35935         return ret_arr;
35936 }
35937
35938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35939         LDKu8slice ser_ref;
35940         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35941         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35942         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
35943         *ret_conv = ChannelUpdate_read(ser_ref);
35944         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35945         return (int64_t)ret_conv;
35946 }
35947
35948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35949         LDKErrorMessage obj_conv;
35950         obj_conv.inner = (void*)(obj & (~1));
35951         obj_conv.is_owned = false;
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35953         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
35954         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35955         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35956         CVec_u8Z_free(ret_var);
35957         return ret_arr;
35958 }
35959
35960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35961         LDKu8slice ser_ref;
35962         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35963         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35964         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
35965         *ret_conv = ErrorMessage_read(ser_ref);
35966         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35967         return (int64_t)ret_conv;
35968 }
35969
35970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35971         LDKWarningMessage obj_conv;
35972         obj_conv.inner = (void*)(obj & (~1));
35973         obj_conv.is_owned = false;
35974         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35975         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
35976         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35977         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35978         CVec_u8Z_free(ret_var);
35979         return ret_arr;
35980 }
35981
35982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35983         LDKu8slice ser_ref;
35984         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35985         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35986         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
35987         *ret_conv = WarningMessage_read(ser_ref);
35988         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35989         return (int64_t)ret_conv;
35990 }
35991
35992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35993         LDKUnsignedNodeAnnouncement obj_conv;
35994         obj_conv.inner = (void*)(obj & (~1));
35995         obj_conv.is_owned = false;
35996         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35997         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
35998         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35999         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36000         CVec_u8Z_free(ret_var);
36001         return ret_arr;
36002 }
36003
36004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36005         LDKu8slice ser_ref;
36006         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36007         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36008         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
36009         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
36010         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36011         return (int64_t)ret_conv;
36012 }
36013
36014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36015         LDKNodeAnnouncement obj_conv;
36016         obj_conv.inner = (void*)(obj & (~1));
36017         obj_conv.is_owned = false;
36018         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36019         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
36020         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36021         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36022         CVec_u8Z_free(ret_var);
36023         return ret_arr;
36024 }
36025
36026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36027         LDKu8slice ser_ref;
36028         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36029         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36030         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
36031         *ret_conv = NodeAnnouncement_read(ser_ref);
36032         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36033         return (int64_t)ret_conv;
36034 }
36035
36036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36037         LDKu8slice ser_ref;
36038         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36039         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36040         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
36041         *ret_conv = QueryShortChannelIds_read(ser_ref);
36042         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36043         return (int64_t)ret_conv;
36044 }
36045
36046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
36047         LDKQueryShortChannelIds obj_conv;
36048         obj_conv.inner = (void*)(obj & (~1));
36049         obj_conv.is_owned = false;
36050         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36051         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
36052         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36053         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36054         CVec_u8Z_free(ret_var);
36055         return ret_arr;
36056 }
36057
36058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
36059         LDKReplyShortChannelIdsEnd obj_conv;
36060         obj_conv.inner = (void*)(obj & (~1));
36061         obj_conv.is_owned = false;
36062         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36063         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
36064         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36065         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36066         CVec_u8Z_free(ret_var);
36067         return ret_arr;
36068 }
36069
36070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36071         LDKu8slice ser_ref;
36072         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36073         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36074         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
36075         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
36076         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36077         return (int64_t)ret_conv;
36078 }
36079
36080 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
36081         LDKQueryChannelRange this_arg_conv;
36082         this_arg_conv.inner = (void*)(this_arg & (~1));
36083         this_arg_conv.is_owned = false;
36084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36085         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
36086         return ret_conv;
36087 }
36088
36089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36090         LDKQueryChannelRange obj_conv;
36091         obj_conv.inner = (void*)(obj & (~1));
36092         obj_conv.is_owned = false;
36093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36094         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
36095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36097         CVec_u8Z_free(ret_var);
36098         return ret_arr;
36099 }
36100
36101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36102         LDKu8slice ser_ref;
36103         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36104         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36105         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
36106         *ret_conv = QueryChannelRange_read(ser_ref);
36107         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36108         return (int64_t)ret_conv;
36109 }
36110
36111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36112         LDKu8slice ser_ref;
36113         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36114         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36115         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
36116         *ret_conv = ReplyChannelRange_read(ser_ref);
36117         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36118         return (int64_t)ret_conv;
36119 }
36120
36121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36122         LDKReplyChannelRange obj_conv;
36123         obj_conv.inner = (void*)(obj & (~1));
36124         obj_conv.is_owned = false;
36125         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36126         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
36127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36129         CVec_u8Z_free(ret_var);
36130         return ret_arr;
36131 }
36132
36133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
36134         LDKGossipTimestampFilter obj_conv;
36135         obj_conv.inner = (void*)(obj & (~1));
36136         obj_conv.is_owned = false;
36137         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36138         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
36139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36141         CVec_u8Z_free(ret_var);
36142         return ret_arr;
36143 }
36144
36145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36146         LDKu8slice ser_ref;
36147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36149         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
36150         *ret_conv = GossipTimestampFilter_read(ser_ref);
36151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36152         return (int64_t)ret_conv;
36153 }
36154
36155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36156         if ((this_ptr & 1) != 0) return;
36157         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36158         CHECK_ACCESS(this_ptr_ptr);
36159         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
36160         FREE((void*)this_ptr);
36161         CustomMessageHandler_free(this_ptr_conv);
36162 }
36163
36164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36165         LDKIgnoringMessageHandler this_obj_conv;
36166         this_obj_conv.inner = (void*)(this_obj & (~1));
36167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36169         IgnoringMessageHandler_free(this_obj_conv);
36170 }
36171
36172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
36173         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
36174         int64_t ret_ref = 0;
36175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36178         ret_ref = (uintptr_t)ret_var.inner;
36179         if (ret_var.is_owned) {
36180                 ret_ref |= 1;
36181         }
36182         return ret_ref;
36183 }
36184
36185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36186         LDKIgnoringMessageHandler this_arg_conv;
36187         this_arg_conv.inner = (void*)(this_arg & (~1));
36188         this_arg_conv.is_owned = false;
36189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36190         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36191         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36192         return (int64_t)ret_ret;
36193 }
36194
36195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36196         LDKIgnoringMessageHandler this_arg_conv;
36197         this_arg_conv.inner = (void*)(this_arg & (~1));
36198         this_arg_conv.is_owned = false;
36199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36200         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36201         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
36202         return (int64_t)ret_ret;
36203 }
36204
36205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
36206         LDKIgnoringMessageHandler this_arg_conv;
36207         this_arg_conv.inner = (void*)(this_arg & (~1));
36208         this_arg_conv.is_owned = false;
36209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36210         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
36211         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
36212         return (int64_t)ret_ret;
36213 }
36214
36215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36216         LDKIgnoringMessageHandler this_arg_conv;
36217         this_arg_conv.inner = (void*)(this_arg & (~1));
36218         this_arg_conv.is_owned = false;
36219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36220         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
36221         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
36222         return (int64_t)ret_ret;
36223 }
36224
36225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36226         LDKErroringMessageHandler this_obj_conv;
36227         this_obj_conv.inner = (void*)(this_obj & (~1));
36228         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36230         ErroringMessageHandler_free(this_obj_conv);
36231 }
36232
36233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
36234         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
36235         int64_t ret_ref = 0;
36236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36239         ret_ref = (uintptr_t)ret_var.inner;
36240         if (ret_var.is_owned) {
36241                 ret_ref |= 1;
36242         }
36243         return ret_ref;
36244 }
36245
36246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36247         LDKErroringMessageHandler this_arg_conv;
36248         this_arg_conv.inner = (void*)(this_arg & (~1));
36249         this_arg_conv.is_owned = false;
36250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36251         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36252         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36253         return (int64_t)ret_ret;
36254 }
36255
36256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36257         LDKErroringMessageHandler this_arg_conv;
36258         this_arg_conv.inner = (void*)(this_arg & (~1));
36259         this_arg_conv.is_owned = false;
36260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36261         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
36262         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
36263         return (int64_t)ret_ret;
36264 }
36265
36266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36267         LDKMessageHandler this_obj_conv;
36268         this_obj_conv.inner = (void*)(this_obj & (~1));
36269         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36271         MessageHandler_free(this_obj_conv);
36272 }
36273
36274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36275         LDKMessageHandler this_ptr_conv;
36276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36277         this_ptr_conv.is_owned = false;
36278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36279         // WARNING: This object doesn't live past this scope, needs clone!
36280         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
36281         return ret_ret;
36282 }
36283
36284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36285         LDKMessageHandler this_ptr_conv;
36286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36287         this_ptr_conv.is_owned = false;
36288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36289         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36290         CHECK_ACCESS(val_ptr);
36291         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
36292         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
36293                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36294                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
36295         }
36296         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
36297 }
36298
36299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36300         LDKMessageHandler 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         // WARNING: This object doesn't live past this scope, needs clone!
36305         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
36306         return ret_ret;
36307 }
36308
36309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36310         LDKMessageHandler this_ptr_conv;
36311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36312         this_ptr_conv.is_owned = false;
36313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36314         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36315         CHECK_ACCESS(val_ptr);
36316         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
36317         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36318                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36319                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
36320         }
36321         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
36322 }
36323
36324 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) {
36325         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
36326         CHECK_ACCESS(chan_handler_arg_ptr);
36327         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
36328         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
36329                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36330                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
36331         }
36332         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
36333         CHECK_ACCESS(route_handler_arg_ptr);
36334         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
36335         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36336                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36337                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
36338         }
36339         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
36340         int64_t ret_ref = 0;
36341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36344         ret_ref = (uintptr_t)ret_var.inner;
36345         if (ret_var.is_owned) {
36346                 ret_ref |= 1;
36347         }
36348         return ret_ref;
36349 }
36350
36351 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
36352         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36353         *ret_ret = SocketDescriptor_clone(arg);
36354         return (int64_t)ret_ret;
36355 }
36356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36357         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
36358         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
36359         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
36360         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
36361         return ret_conv;
36362 }
36363
36364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36365         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
36366         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
36367         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
36368         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36369         *ret_ret = SocketDescriptor_clone(orig_conv);
36370         return (int64_t)ret_ret;
36371 }
36372
36373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36374         if ((this_ptr & 1) != 0) return;
36375         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36376         CHECK_ACCESS(this_ptr_ptr);
36377         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
36378         FREE((void*)this_ptr);
36379         SocketDescriptor_free(this_ptr_conv);
36380 }
36381
36382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36383         LDKPeerHandleError this_obj_conv;
36384         this_obj_conv.inner = (void*)(this_obj & (~1));
36385         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36387         PeerHandleError_free(this_obj_conv);
36388 }
36389
36390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
36391         LDKPeerHandleError this_ptr_conv;
36392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36393         this_ptr_conv.is_owned = false;
36394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36395         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
36396         return ret_conv;
36397 }
36398
36399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36400         LDKPeerHandleError this_ptr_conv;
36401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36402         this_ptr_conv.is_owned = false;
36403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36404         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
36405 }
36406
36407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
36408         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
36409         int64_t ret_ref = 0;
36410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36413         ret_ref = (uintptr_t)ret_var.inner;
36414         if (ret_var.is_owned) {
36415                 ret_ref |= 1;
36416         }
36417         return ret_ref;
36418 }
36419
36420 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
36421         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
36422 int64_t ret_ref = 0;
36423 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36424 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36425 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36426 ret_ref = (uintptr_t)ret_var.inner;
36427 if (ret_var.is_owned) {
36428         ret_ref |= 1;
36429 }
36430         return ret_ref;
36431 }
36432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36433         LDKPeerHandleError arg_conv;
36434         arg_conv.inner = (void*)(arg & (~1));
36435         arg_conv.is_owned = false;
36436         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36437         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
36438         return ret_conv;
36439 }
36440
36441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36442         LDKPeerHandleError orig_conv;
36443         orig_conv.inner = (void*)(orig & (~1));
36444         orig_conv.is_owned = false;
36445         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36446         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
36447         int64_t ret_ref = 0;
36448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36451         ret_ref = (uintptr_t)ret_var.inner;
36452         if (ret_var.is_owned) {
36453                 ret_ref |= 1;
36454         }
36455         return ret_ref;
36456 }
36457
36458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36459         LDKPeerManager this_obj_conv;
36460         this_obj_conv.inner = (void*)(this_obj & (~1));
36461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36463         PeerManager_free(this_obj_conv);
36464 }
36465
36466 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) {
36467         LDKMessageHandler message_handler_conv;
36468         message_handler_conv.inner = (void*)(message_handler & (~1));
36469         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
36470         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
36471         // WARNING: we need a move here but no clone is available for LDKMessageHandler
36472         LDKSecretKey our_node_secret_ref;
36473         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
36474         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
36475         unsigned char ephemeral_random_data_arr[32];
36476         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
36477         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
36478         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
36479         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36480         CHECK_ACCESS(logger_ptr);
36481         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36482         if (logger_conv.free == LDKLogger_JCalls_free) {
36483                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36484                 LDKLogger_JCalls_cloned(&logger_conv);
36485         }
36486         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
36487         CHECK_ACCESS(custom_message_handler_ptr);
36488         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
36489         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
36490                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36491                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
36492         }
36493         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
36494         int64_t ret_ref = 0;
36495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36498         ret_ref = (uintptr_t)ret_var.inner;
36499         if (ret_var.is_owned) {
36500                 ret_ref |= 1;
36501         }
36502         return ret_ref;
36503 }
36504
36505 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
36506         LDKPeerManager this_arg_conv;
36507         this_arg_conv.inner = (void*)(this_arg & (~1));
36508         this_arg_conv.is_owned = false;
36509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36510         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
36511         jobjectArray ret_arr = NULL;
36512         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
36513         ;
36514         for (size_t i = 0; i < ret_var.datalen; i++) {
36515                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
36516                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
36517                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
36518         }
36519         
36520         FREE(ret_var.data);
36521         return ret_arr;
36522 }
36523
36524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t descriptor, int64_t remote_network_address) {
36525         LDKPeerManager this_arg_conv;
36526         this_arg_conv.inner = (void*)(this_arg & (~1));
36527         this_arg_conv.is_owned = false;
36528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36529         LDKPublicKey their_node_id_ref;
36530         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
36531         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
36532         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36533         CHECK_ACCESS(descriptor_ptr);
36534         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36535         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36536                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36537                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36538         }
36539         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
36540         CHECK_ACCESS(remote_network_address_ptr);
36541         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36542         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
36543         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
36544         return (int64_t)ret_conv;
36545 }
36546
36547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor, int64_t remote_network_address) {
36548         LDKPeerManager this_arg_conv;
36549         this_arg_conv.inner = (void*)(this_arg & (~1));
36550         this_arg_conv.is_owned = false;
36551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36552         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36553         CHECK_ACCESS(descriptor_ptr);
36554         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36555         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36556                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36557                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36558         }
36559         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
36560         CHECK_ACCESS(remote_network_address_ptr);
36561         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36562         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36563         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
36564         return (int64_t)ret_conv;
36565 }
36566
36567 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) {
36568         LDKPeerManager this_arg_conv;
36569         this_arg_conv.inner = (void*)(this_arg & (~1));
36570         this_arg_conv.is_owned = false;
36571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36572         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36573         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36574         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36575         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36576         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
36577         return (int64_t)ret_conv;
36578 }
36579
36580 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) {
36581         LDKPeerManager this_arg_conv;
36582         this_arg_conv.inner = (void*)(this_arg & (~1));
36583         this_arg_conv.is_owned = false;
36584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36585         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
36586         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
36587         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
36588         LDKu8slice data_ref;
36589         data_ref.datalen = (*env)->GetArrayLength(env, data);
36590         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
36591         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
36592         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
36593         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
36594         return (int64_t)ret_conv;
36595 }
36596
36597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
36598         LDKPeerManager this_arg_conv;
36599         this_arg_conv.inner = (void*)(this_arg & (~1));
36600         this_arg_conv.is_owned = false;
36601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36602         PeerManager_process_events(&this_arg_conv);
36603 }
36604
36605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
36606         LDKPeerManager this_arg_conv;
36607         this_arg_conv.inner = (void*)(this_arg & (~1));
36608         this_arg_conv.is_owned = false;
36609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36610         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36611         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36612         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36613         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
36614 }
36615
36616 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) {
36617         LDKPeerManager this_arg_conv;
36618         this_arg_conv.inner = (void*)(this_arg & (~1));
36619         this_arg_conv.is_owned = false;
36620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36621         LDKPublicKey node_id_ref;
36622         CHECK((*env)->GetArrayLength(env, node_id) == 33);
36623         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
36624         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
36625 }
36626
36627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
36628         LDKPeerManager this_arg_conv;
36629         this_arg_conv.inner = (void*)(this_arg & (~1));
36630         this_arg_conv.is_owned = false;
36631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36632         PeerManager_disconnect_all_peers(&this_arg_conv);
36633 }
36634
36635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
36636         LDKPeerManager this_arg_conv;
36637         this_arg_conv.inner = (void*)(this_arg & (~1));
36638         this_arg_conv.is_owned = false;
36639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36640         PeerManager_timer_tick_occurred(&this_arg_conv);
36641 }
36642
36643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36644         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
36645         return ret_conv;
36646 }
36647
36648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36649         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
36650         return ret_conv;
36651 }
36652
36653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
36654         unsigned char commitment_seed_arr[32];
36655         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
36656         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
36657         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
36658         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36659         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
36660         return ret_arr;
36661 }
36662
36663 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) {
36664         LDKCVec_u8Z to_holder_script_ref;
36665         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
36666         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36667         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
36668         LDKCVec_u8Z to_counterparty_script_ref;
36669         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
36670         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36671         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
36672         LDKOutPoint funding_outpoint_conv;
36673         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36674         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36675         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36676         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36677         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);
36678         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36679         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36680         Transaction_free(ret_var);
36681         return ret_arr;
36682 }
36683
36684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36685         LDKCounterpartyCommitmentSecrets this_obj_conv;
36686         this_obj_conv.inner = (void*)(this_obj & (~1));
36687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36689         CounterpartyCommitmentSecrets_free(this_obj_conv);
36690 }
36691
36692 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
36693         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
36694 int64_t ret_ref = 0;
36695 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36696 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36697 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36698 ret_ref = (uintptr_t)ret_var.inner;
36699 if (ret_var.is_owned) {
36700         ret_ref |= 1;
36701 }
36702         return ret_ref;
36703 }
36704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36705         LDKCounterpartyCommitmentSecrets arg_conv;
36706         arg_conv.inner = (void*)(arg & (~1));
36707         arg_conv.is_owned = false;
36708         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36709         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
36710         return ret_conv;
36711 }
36712
36713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36714         LDKCounterpartyCommitmentSecrets orig_conv;
36715         orig_conv.inner = (void*)(orig & (~1));
36716         orig_conv.is_owned = false;
36717         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36718         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
36719         int64_t ret_ref = 0;
36720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36723         ret_ref = (uintptr_t)ret_var.inner;
36724         if (ret_var.is_owned) {
36725                 ret_ref |= 1;
36726         }
36727         return ret_ref;
36728 }
36729
36730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
36731         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
36732         int64_t ret_ref = 0;
36733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36736         ret_ref = (uintptr_t)ret_var.inner;
36737         if (ret_var.is_owned) {
36738                 ret_ref |= 1;
36739         }
36740         return ret_ref;
36741 }
36742
36743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
36744         LDKCounterpartyCommitmentSecrets this_arg_conv;
36745         this_arg_conv.inner = (void*)(this_arg & (~1));
36746         this_arg_conv.is_owned = false;
36747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36748         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
36749         return ret_conv;
36750 }
36751
36752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1provide_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
36753         LDKCounterpartyCommitmentSecrets this_arg_conv;
36754         this_arg_conv.inner = (void*)(this_arg & (~1));
36755         this_arg_conv.is_owned = false;
36756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36757         LDKThirtyTwoBytes secret_ref;
36758         CHECK((*env)->GetArrayLength(env, secret) == 32);
36759         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
36760         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
36761         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
36762         return (int64_t)ret_conv;
36763 }
36764
36765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
36766         LDKCounterpartyCommitmentSecrets this_arg_conv;
36767         this_arg_conv.inner = (void*)(this_arg & (~1));
36768         this_arg_conv.is_owned = false;
36769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36770         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
36772         return ret_arr;
36773 }
36774
36775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
36776         LDKCounterpartyCommitmentSecrets obj_conv;
36777         obj_conv.inner = (void*)(obj & (~1));
36778         obj_conv.is_owned = false;
36779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36780         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
36781         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36782         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36783         CVec_u8Z_free(ret_var);
36784         return ret_arr;
36785 }
36786
36787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36788         LDKu8slice ser_ref;
36789         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36790         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36791         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
36792         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
36793         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36794         return (int64_t)ret_conv;
36795 }
36796
36797 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) {
36798         LDKPublicKey per_commitment_point_ref;
36799         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36800         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36801         unsigned char base_secret_arr[32];
36802         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
36803         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
36804         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
36805         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36806         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
36807         return (int64_t)ret_conv;
36808 }
36809
36810 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) {
36811         LDKPublicKey per_commitment_point_ref;
36812         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36813         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36814         LDKPublicKey base_point_ref;
36815         CHECK((*env)->GetArrayLength(env, base_point) == 33);
36816         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
36817         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36818         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
36819         return (int64_t)ret_conv;
36820 }
36821
36822 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) {
36823         unsigned char per_commitment_secret_arr[32];
36824         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
36825         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
36826         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
36827         unsigned char countersignatory_revocation_base_secret_arr[32];
36828         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
36829         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
36830         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
36831         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36832         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
36833         return (int64_t)ret_conv;
36834 }
36835
36836 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) {
36837         LDKPublicKey per_commitment_point_ref;
36838         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36839         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36840         LDKPublicKey countersignatory_revocation_base_point_ref;
36841         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
36842         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
36843         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36844         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
36845         return (int64_t)ret_conv;
36846 }
36847
36848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36849         LDKTxCreationKeys this_obj_conv;
36850         this_obj_conv.inner = (void*)(this_obj & (~1));
36851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36853         TxCreationKeys_free(this_obj_conv);
36854 }
36855
36856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36857         LDKTxCreationKeys this_ptr_conv;
36858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36859         this_ptr_conv.is_owned = false;
36860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36861         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36862         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
36863         return ret_arr;
36864 }
36865
36866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36867         LDKTxCreationKeys this_ptr_conv;
36868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36869         this_ptr_conv.is_owned = false;
36870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36871         LDKPublicKey val_ref;
36872         CHECK((*env)->GetArrayLength(env, val) == 33);
36873         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36874         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
36875 }
36876
36877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36878         LDKTxCreationKeys this_ptr_conv;
36879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36880         this_ptr_conv.is_owned = false;
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36882         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36883         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
36884         return ret_arr;
36885 }
36886
36887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36888         LDKTxCreationKeys this_ptr_conv;
36889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36890         this_ptr_conv.is_owned = false;
36891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36892         LDKPublicKey val_ref;
36893         CHECK((*env)->GetArrayLength(env, val) == 33);
36894         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36895         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
36896 }
36897
36898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36899         LDKTxCreationKeys this_ptr_conv;
36900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36901         this_ptr_conv.is_owned = false;
36902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36903         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36904         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
36905         return ret_arr;
36906 }
36907
36908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36909         LDKTxCreationKeys this_ptr_conv;
36910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36911         this_ptr_conv.is_owned = false;
36912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36913         LDKPublicKey val_ref;
36914         CHECK((*env)->GetArrayLength(env, val) == 33);
36915         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36916         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
36917 }
36918
36919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36920         LDKTxCreationKeys this_ptr_conv;
36921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36922         this_ptr_conv.is_owned = false;
36923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36924         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36925         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
36926         return ret_arr;
36927 }
36928
36929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36930         LDKTxCreationKeys this_ptr_conv;
36931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36932         this_ptr_conv.is_owned = false;
36933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36934         LDKPublicKey val_ref;
36935         CHECK((*env)->GetArrayLength(env, val) == 33);
36936         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36937         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
36938 }
36939
36940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36941         LDKTxCreationKeys this_ptr_conv;
36942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36943         this_ptr_conv.is_owned = false;
36944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36945         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36946         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
36947         return ret_arr;
36948 }
36949
36950 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) {
36951         LDKTxCreationKeys this_ptr_conv;
36952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36953         this_ptr_conv.is_owned = false;
36954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36955         LDKPublicKey val_ref;
36956         CHECK((*env)->GetArrayLength(env, val) == 33);
36957         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36958         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
36959 }
36960
36961 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) {
36962         LDKPublicKey per_commitment_point_arg_ref;
36963         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
36964         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
36965         LDKPublicKey revocation_key_arg_ref;
36966         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
36967         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
36968         LDKPublicKey broadcaster_htlc_key_arg_ref;
36969         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
36970         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
36971         LDKPublicKey countersignatory_htlc_key_arg_ref;
36972         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
36973         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
36974         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
36975         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
36976         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
36977         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);
36978         int64_t ret_ref = 0;
36979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36982         ret_ref = (uintptr_t)ret_var.inner;
36983         if (ret_var.is_owned) {
36984                 ret_ref |= 1;
36985         }
36986         return ret_ref;
36987 }
36988
36989 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
36990         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
36991 int64_t ret_ref = 0;
36992 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36993 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36994 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36995 ret_ref = (uintptr_t)ret_var.inner;
36996 if (ret_var.is_owned) {
36997         ret_ref |= 1;
36998 }
36999         return ret_ref;
37000 }
37001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37002         LDKTxCreationKeys arg_conv;
37003         arg_conv.inner = (void*)(arg & (~1));
37004         arg_conv.is_owned = false;
37005         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37006         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
37007         return ret_conv;
37008 }
37009
37010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37011         LDKTxCreationKeys orig_conv;
37012         orig_conv.inner = (void*)(orig & (~1));
37013         orig_conv.is_owned = false;
37014         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37015         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
37016         int64_t ret_ref = 0;
37017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37020         ret_ref = (uintptr_t)ret_var.inner;
37021         if (ret_var.is_owned) {
37022                 ret_ref |= 1;
37023         }
37024         return ret_ref;
37025 }
37026
37027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37028         LDKTxCreationKeys obj_conv;
37029         obj_conv.inner = (void*)(obj & (~1));
37030         obj_conv.is_owned = false;
37031         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37032         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
37033         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37034         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37035         CVec_u8Z_free(ret_var);
37036         return ret_arr;
37037 }
37038
37039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37040         LDKu8slice ser_ref;
37041         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37042         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37043         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
37044         *ret_conv = TxCreationKeys_read(ser_ref);
37045         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37046         return (int64_t)ret_conv;
37047 }
37048
37049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37050         LDKChannelPublicKeys this_obj_conv;
37051         this_obj_conv.inner = (void*)(this_obj & (~1));
37052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37054         ChannelPublicKeys_free(this_obj_conv);
37055 }
37056
37057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
37058         LDKChannelPublicKeys this_ptr_conv;
37059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37060         this_ptr_conv.is_owned = false;
37061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37062         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
37064         return ret_arr;
37065 }
37066
37067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37068         LDKChannelPublicKeys this_ptr_conv;
37069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37070         this_ptr_conv.is_owned = false;
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37072         LDKPublicKey val_ref;
37073         CHECK((*env)->GetArrayLength(env, val) == 33);
37074         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37075         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
37076 }
37077
37078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37079         LDKChannelPublicKeys this_ptr_conv;
37080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37081         this_ptr_conv.is_owned = false;
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37083         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
37085         return ret_arr;
37086 }
37087
37088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37089         LDKChannelPublicKeys this_ptr_conv;
37090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37091         this_ptr_conv.is_owned = false;
37092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37093         LDKPublicKey val_ref;
37094         CHECK((*env)->GetArrayLength(env, val) == 33);
37095         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37096         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
37097 }
37098
37099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37100         LDKChannelPublicKeys this_ptr_conv;
37101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37102         this_ptr_conv.is_owned = false;
37103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37104         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
37106         return ret_arr;
37107 }
37108
37109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37110         LDKChannelPublicKeys this_ptr_conv;
37111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37112         this_ptr_conv.is_owned = false;
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37114         LDKPublicKey val_ref;
37115         CHECK((*env)->GetArrayLength(env, val) == 33);
37116         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37117         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
37118 }
37119
37120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37121         LDKChannelPublicKeys this_ptr_conv;
37122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37123         this_ptr_conv.is_owned = false;
37124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37125         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
37127         return ret_arr;
37128 }
37129
37130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37131         LDKChannelPublicKeys this_ptr_conv;
37132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37133         this_ptr_conv.is_owned = false;
37134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37135         LDKPublicKey val_ref;
37136         CHECK((*env)->GetArrayLength(env, val) == 33);
37137         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37138         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
37139 }
37140
37141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37142         LDKChannelPublicKeys this_ptr_conv;
37143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37144         this_ptr_conv.is_owned = false;
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37146         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
37148         return ret_arr;
37149 }
37150
37151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37152         LDKChannelPublicKeys this_ptr_conv;
37153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37154         this_ptr_conv.is_owned = false;
37155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37156         LDKPublicKey val_ref;
37157         CHECK((*env)->GetArrayLength(env, val) == 33);
37158         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37159         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
37160 }
37161
37162 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) {
37163         LDKPublicKey funding_pubkey_arg_ref;
37164         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
37165         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
37166         LDKPublicKey revocation_basepoint_arg_ref;
37167         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
37168         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
37169         LDKPublicKey payment_point_arg_ref;
37170         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
37171         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
37172         LDKPublicKey delayed_payment_basepoint_arg_ref;
37173         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
37174         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
37175         LDKPublicKey htlc_basepoint_arg_ref;
37176         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
37177         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
37178         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);
37179         int64_t ret_ref = 0;
37180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37183         ret_ref = (uintptr_t)ret_var.inner;
37184         if (ret_var.is_owned) {
37185                 ret_ref |= 1;
37186         }
37187         return ret_ref;
37188 }
37189
37190 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
37191         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
37192 int64_t ret_ref = 0;
37193 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37194 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37195 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37196 ret_ref = (uintptr_t)ret_var.inner;
37197 if (ret_var.is_owned) {
37198         ret_ref |= 1;
37199 }
37200         return ret_ref;
37201 }
37202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37203         LDKChannelPublicKeys arg_conv;
37204         arg_conv.inner = (void*)(arg & (~1));
37205         arg_conv.is_owned = false;
37206         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37207         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
37208         return ret_conv;
37209 }
37210
37211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37212         LDKChannelPublicKeys orig_conv;
37213         orig_conv.inner = (void*)(orig & (~1));
37214         orig_conv.is_owned = false;
37215         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37216         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
37217         int64_t ret_ref = 0;
37218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37221         ret_ref = (uintptr_t)ret_var.inner;
37222         if (ret_var.is_owned) {
37223                 ret_ref |= 1;
37224         }
37225         return ret_ref;
37226 }
37227
37228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37229         LDKChannelPublicKeys obj_conv;
37230         obj_conv.inner = (void*)(obj & (~1));
37231         obj_conv.is_owned = false;
37232         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37233         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
37234         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37235         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37236         CVec_u8Z_free(ret_var);
37237         return ret_arr;
37238 }
37239
37240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37241         LDKu8slice ser_ref;
37242         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37243         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37244         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
37245         *ret_conv = ChannelPublicKeys_read(ser_ref);
37246         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37247         return (int64_t)ret_conv;
37248 }
37249
37250 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) {
37251         LDKPublicKey per_commitment_point_ref;
37252         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37253         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37254         LDKPublicKey broadcaster_delayed_payment_base_ref;
37255         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
37256         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
37257         LDKPublicKey broadcaster_htlc_base_ref;
37258         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
37259         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
37260         LDKPublicKey countersignatory_revocation_base_ref;
37261         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
37262         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
37263         LDKPublicKey countersignatory_htlc_base_ref;
37264         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
37265         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
37266         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37267         *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);
37268         return (int64_t)ret_conv;
37269 }
37270
37271 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) {
37272         LDKPublicKey per_commitment_point_ref;
37273         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37274         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37275         LDKChannelPublicKeys broadcaster_keys_conv;
37276         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37277         broadcaster_keys_conv.is_owned = false;
37278         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37279         LDKChannelPublicKeys countersignatory_keys_conv;
37280         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37281         countersignatory_keys_conv.is_owned = false;
37282         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37283         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37284         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
37285         return (int64_t)ret_conv;
37286 }
37287
37288 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) {
37289         LDKPublicKey revocation_key_ref;
37290         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37291         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37292         LDKPublicKey broadcaster_delayed_payment_key_ref;
37293         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37294         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37295         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
37296         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37297         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37298         CVec_u8Z_free(ret_var);
37299         return ret_arr;
37300 }
37301
37302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37303         LDKHTLCOutputInCommitment this_obj_conv;
37304         this_obj_conv.inner = (void*)(this_obj & (~1));
37305         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37307         HTLCOutputInCommitment_free(this_obj_conv);
37308 }
37309
37310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
37311         LDKHTLCOutputInCommitment this_ptr_conv;
37312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37313         this_ptr_conv.is_owned = false;
37314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37315         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
37316         return ret_conv;
37317 }
37318
37319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37320         LDKHTLCOutputInCommitment this_ptr_conv;
37321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37322         this_ptr_conv.is_owned = false;
37323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37324         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
37325 }
37326
37327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37328         LDKHTLCOutputInCommitment this_ptr_conv;
37329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37330         this_ptr_conv.is_owned = false;
37331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37332         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
37333         return ret_conv;
37334 }
37335
37336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37337         LDKHTLCOutputInCommitment this_ptr_conv;
37338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37339         this_ptr_conv.is_owned = false;
37340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37341         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
37342 }
37343
37344 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
37345         LDKHTLCOutputInCommitment this_ptr_conv;
37346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37347         this_ptr_conv.is_owned = false;
37348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37349         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
37350         return ret_conv;
37351 }
37352
37353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37354         LDKHTLCOutputInCommitment this_ptr_conv;
37355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37356         this_ptr_conv.is_owned = false;
37357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37358         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
37359 }
37360
37361 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37362         LDKHTLCOutputInCommitment this_ptr_conv;
37363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37364         this_ptr_conv.is_owned = false;
37365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37366         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37367         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
37368         return ret_arr;
37369 }
37370
37371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37372         LDKHTLCOutputInCommitment this_ptr_conv;
37373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37374         this_ptr_conv.is_owned = false;
37375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37376         LDKThirtyTwoBytes val_ref;
37377         CHECK((*env)->GetArrayLength(env, val) == 32);
37378         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37379         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
37380 }
37381
37382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
37383         LDKHTLCOutputInCommitment this_ptr_conv;
37384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37385         this_ptr_conv.is_owned = false;
37386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37387         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
37388         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
37389         int64_t ret_ref = (uintptr_t)ret_copy;
37390         return ret_ref;
37391 }
37392
37393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37394         LDKHTLCOutputInCommitment this_ptr_conv;
37395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37396         this_ptr_conv.is_owned = false;
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37398         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37399         CHECK_ACCESS(val_ptr);
37400         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
37401         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
37402         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
37403 }
37404
37405 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) {
37406         LDKThirtyTwoBytes payment_hash_arg_ref;
37407         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
37408         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
37409         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
37410         CHECK_ACCESS(transaction_output_index_arg_ptr);
37411         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
37412         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
37413         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
37414         int64_t ret_ref = 0;
37415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37418         ret_ref = (uintptr_t)ret_var.inner;
37419         if (ret_var.is_owned) {
37420                 ret_ref |= 1;
37421         }
37422         return ret_ref;
37423 }
37424
37425 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
37426         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
37427 int64_t ret_ref = 0;
37428 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37429 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37430 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37431 ret_ref = (uintptr_t)ret_var.inner;
37432 if (ret_var.is_owned) {
37433         ret_ref |= 1;
37434 }
37435         return ret_ref;
37436 }
37437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37438         LDKHTLCOutputInCommitment arg_conv;
37439         arg_conv.inner = (void*)(arg & (~1));
37440         arg_conv.is_owned = false;
37441         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37442         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
37443         return ret_conv;
37444 }
37445
37446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37447         LDKHTLCOutputInCommitment orig_conv;
37448         orig_conv.inner = (void*)(orig & (~1));
37449         orig_conv.is_owned = false;
37450         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37451         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
37452         int64_t ret_ref = 0;
37453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37456         ret_ref = (uintptr_t)ret_var.inner;
37457         if (ret_var.is_owned) {
37458                 ret_ref |= 1;
37459         }
37460         return ret_ref;
37461 }
37462
37463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
37464         LDKHTLCOutputInCommitment obj_conv;
37465         obj_conv.inner = (void*)(obj & (~1));
37466         obj_conv.is_owned = false;
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37468         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
37469         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37470         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37471         CVec_u8Z_free(ret_var);
37472         return ret_arr;
37473 }
37474
37475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37476         LDKu8slice ser_ref;
37477         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37478         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37479         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
37480         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
37481         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37482         return (int64_t)ret_conv;
37483 }
37484
37485 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) {
37486         LDKHTLCOutputInCommitment htlc_conv;
37487         htlc_conv.inner = (void*)(htlc & (~1));
37488         htlc_conv.is_owned = false;
37489         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37490         LDKTxCreationKeys keys_conv;
37491         keys_conv.inner = (void*)(keys & (~1));
37492         keys_conv.is_owned = false;
37493         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37494         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
37495         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37496         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37497         CVec_u8Z_free(ret_var);
37498         return ret_arr;
37499 }
37500
37501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
37502         LDKPublicKey broadcaster_ref;
37503         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
37504         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
37505         LDKPublicKey countersignatory_ref;
37506         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
37507         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
37508         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
37509         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37510         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37511         CVec_u8Z_free(ret_var);
37512         return ret_arr;
37513 }
37514
37515 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) {
37516         unsigned char commitment_txid_arr[32];
37517         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
37518         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
37519         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
37520         LDKHTLCOutputInCommitment htlc_conv;
37521         htlc_conv.inner = (void*)(htlc & (~1));
37522         htlc_conv.is_owned = false;
37523         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37524         LDKPublicKey broadcaster_delayed_payment_key_ref;
37525         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37526         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37527         LDKPublicKey revocation_key_ref;
37528         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37529         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37530         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);
37531         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37532         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37533         Transaction_free(ret_var);
37534         return ret_arr;
37535 }
37536
37537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
37538         LDKPublicKey funding_pubkey_ref;
37539         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
37540         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
37541         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
37542         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37543         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37544         CVec_u8Z_free(ret_var);
37545         return ret_arr;
37546 }
37547
37548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37549         LDKChannelTransactionParameters this_obj_conv;
37550         this_obj_conv.inner = (void*)(this_obj & (~1));
37551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37553         ChannelTransactionParameters_free(this_obj_conv);
37554 }
37555
37556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37557         LDKChannelTransactionParameters this_ptr_conv;
37558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37559         this_ptr_conv.is_owned = false;
37560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37561         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
37562         int64_t ret_ref = 0;
37563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37566         ret_ref = (uintptr_t)ret_var.inner;
37567         if (ret_var.is_owned) {
37568                 ret_ref |= 1;
37569         }
37570         return ret_ref;
37571 }
37572
37573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37574         LDKChannelTransactionParameters this_ptr_conv;
37575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37576         this_ptr_conv.is_owned = false;
37577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37578         LDKChannelPublicKeys val_conv;
37579         val_conv.inner = (void*)(val & (~1));
37580         val_conv.is_owned = (val & 1) || (val == 0);
37581         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37582         val_conv = ChannelPublicKeys_clone(&val_conv);
37583         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
37584 }
37585
37586 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37587         LDKChannelTransactionParameters this_ptr_conv;
37588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37589         this_ptr_conv.is_owned = false;
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37591         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
37592         return ret_conv;
37593 }
37594
37595 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) {
37596         LDKChannelTransactionParameters this_ptr_conv;
37597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37598         this_ptr_conv.is_owned = false;
37599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37600         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
37601 }
37602
37603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
37604         LDKChannelTransactionParameters this_ptr_conv;
37605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37606         this_ptr_conv.is_owned = false;
37607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37608         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
37609         return ret_conv;
37610 }
37611
37612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37613         LDKChannelTransactionParameters this_ptr_conv;
37614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37615         this_ptr_conv.is_owned = false;
37616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37617         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
37618 }
37619
37620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
37621         LDKChannelTransactionParameters this_ptr_conv;
37622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37623         this_ptr_conv.is_owned = false;
37624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37625         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
37626         int64_t ret_ref = 0;
37627         if ((uintptr_t)ret_var.inner > 4096) {
37628                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37629                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37631                 ret_ref = (uintptr_t)ret_var.inner;
37632                 if (ret_var.is_owned) {
37633                         ret_ref |= 1;
37634                 }
37635         }
37636         return ret_ref;
37637 }
37638
37639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37640         LDKChannelTransactionParameters this_ptr_conv;
37641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37642         this_ptr_conv.is_owned = false;
37643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37644         LDKCounterpartyChannelTransactionParameters val_conv;
37645         val_conv.inner = (void*)(val & (~1));
37646         val_conv.is_owned = (val & 1) || (val == 0);
37647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37648         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
37649         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
37650 }
37651
37652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37653         LDKChannelTransactionParameters this_ptr_conv;
37654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37655         this_ptr_conv.is_owned = false;
37656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37657         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
37658         int64_t ret_ref = 0;
37659         if ((uintptr_t)ret_var.inner > 4096) {
37660                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37661                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37663                 ret_ref = (uintptr_t)ret_var.inner;
37664                 if (ret_var.is_owned) {
37665                         ret_ref |= 1;
37666                 }
37667         }
37668         return ret_ref;
37669 }
37670
37671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37672         LDKChannelTransactionParameters this_ptr_conv;
37673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37674         this_ptr_conv.is_owned = false;
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37676         LDKOutPoint val_conv;
37677         val_conv.inner = (void*)(val & (~1));
37678         val_conv.is_owned = (val & 1) || (val == 0);
37679         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37680         val_conv = OutPoint_clone(&val_conv);
37681         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
37682 }
37683
37684 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
37685         LDKChannelTransactionParameters this_ptr_conv;
37686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37687         this_ptr_conv.is_owned = false;
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37689         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
37690         return ret_conv;
37691 }
37692
37693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
37694         LDKChannelTransactionParameters this_ptr_conv;
37695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37696         this_ptr_conv.is_owned = false;
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37698         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
37699         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
37700 }
37701
37702 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) {
37703         LDKChannelPublicKeys holder_pubkeys_arg_conv;
37704         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
37705         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
37706         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
37707         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
37708         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
37709         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
37710         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
37711         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
37712         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
37713         LDKOutPoint funding_outpoint_arg_conv;
37714         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
37715         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
37716         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
37717         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
37718         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
37719         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);
37720         int64_t ret_ref = 0;
37721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37724         ret_ref = (uintptr_t)ret_var.inner;
37725         if (ret_var.is_owned) {
37726                 ret_ref |= 1;
37727         }
37728         return ret_ref;
37729 }
37730
37731 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
37732         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
37733 int64_t ret_ref = 0;
37734 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37735 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37737 ret_ref = (uintptr_t)ret_var.inner;
37738 if (ret_var.is_owned) {
37739         ret_ref |= 1;
37740 }
37741         return ret_ref;
37742 }
37743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37744         LDKChannelTransactionParameters arg_conv;
37745         arg_conv.inner = (void*)(arg & (~1));
37746         arg_conv.is_owned = false;
37747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37748         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
37749         return ret_conv;
37750 }
37751
37752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37753         LDKChannelTransactionParameters orig_conv;
37754         orig_conv.inner = (void*)(orig & (~1));
37755         orig_conv.is_owned = false;
37756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37757         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
37758         int64_t ret_ref = 0;
37759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37762         ret_ref = (uintptr_t)ret_var.inner;
37763         if (ret_var.is_owned) {
37764                 ret_ref |= 1;
37765         }
37766         return ret_ref;
37767 }
37768
37769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37770         LDKCounterpartyChannelTransactionParameters this_obj_conv;
37771         this_obj_conv.inner = (void*)(this_obj & (~1));
37772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37774         CounterpartyChannelTransactionParameters_free(this_obj_conv);
37775 }
37776
37777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37778         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37780         this_ptr_conv.is_owned = false;
37781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37782         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
37783         int64_t ret_ref = 0;
37784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37787         ret_ref = (uintptr_t)ret_var.inner;
37788         if (ret_var.is_owned) {
37789                 ret_ref |= 1;
37790         }
37791         return ret_ref;
37792 }
37793
37794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37795         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37797         this_ptr_conv.is_owned = false;
37798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37799         LDKChannelPublicKeys val_conv;
37800         val_conv.inner = (void*)(val & (~1));
37801         val_conv.is_owned = (val & 1) || (val == 0);
37802         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37803         val_conv = ChannelPublicKeys_clone(&val_conv);
37804         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
37805 }
37806
37807 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37808         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37810         this_ptr_conv.is_owned = false;
37811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37812         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
37813         return ret_conv;
37814 }
37815
37816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37817         LDKCounterpartyChannelTransactionParameters 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         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
37822 }
37823
37824 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) {
37825         LDKChannelPublicKeys pubkeys_arg_conv;
37826         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
37827         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
37828         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
37829         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
37830         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
37831         int64_t ret_ref = 0;
37832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37835         ret_ref = (uintptr_t)ret_var.inner;
37836         if (ret_var.is_owned) {
37837                 ret_ref |= 1;
37838         }
37839         return ret_ref;
37840 }
37841
37842 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
37843         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
37844 int64_t ret_ref = 0;
37845 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37846 CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
37849 if (ret_var.is_owned) {
37850         ret_ref |= 1;
37851 }
37852         return ret_ref;
37853 }
37854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37855         LDKCounterpartyChannelTransactionParameters arg_conv;
37856         arg_conv.inner = (void*)(arg & (~1));
37857         arg_conv.is_owned = false;
37858         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37859         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
37860         return ret_conv;
37861 }
37862
37863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37864         LDKCounterpartyChannelTransactionParameters orig_conv;
37865         orig_conv.inner = (void*)(orig & (~1));
37866         orig_conv.is_owned = false;
37867         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37868         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
37869         int64_t ret_ref = 0;
37870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37873         ret_ref = (uintptr_t)ret_var.inner;
37874         if (ret_var.is_owned) {
37875                 ret_ref |= 1;
37876         }
37877         return ret_ref;
37878 }
37879
37880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
37881         LDKChannelTransactionParameters this_arg_conv;
37882         this_arg_conv.inner = (void*)(this_arg & (~1));
37883         this_arg_conv.is_owned = false;
37884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37885         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
37886         return ret_conv;
37887 }
37888
37889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37890         LDKChannelTransactionParameters this_arg_conv;
37891         this_arg_conv.inner = (void*)(this_arg & (~1));
37892         this_arg_conv.is_owned = false;
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37894         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
37895         int64_t ret_ref = 0;
37896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37899         ret_ref = (uintptr_t)ret_var.inner;
37900         if (ret_var.is_owned) {
37901                 ret_ref |= 1;
37902         }
37903         return ret_ref;
37904 }
37905
37906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37907         LDKChannelTransactionParameters this_arg_conv;
37908         this_arg_conv.inner = (void*)(this_arg & (~1));
37909         this_arg_conv.is_owned = false;
37910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37911         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
37912         int64_t ret_ref = 0;
37913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37916         ret_ref = (uintptr_t)ret_var.inner;
37917         if (ret_var.is_owned) {
37918                 ret_ref |= 1;
37919         }
37920         return ret_ref;
37921 }
37922
37923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37924         LDKCounterpartyChannelTransactionParameters obj_conv;
37925         obj_conv.inner = (void*)(obj & (~1));
37926         obj_conv.is_owned = false;
37927         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37928         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
37929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37931         CVec_u8Z_free(ret_var);
37932         return ret_arr;
37933 }
37934
37935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37936         LDKu8slice ser_ref;
37937         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37938         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37939         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
37940         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
37941         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37942         return (int64_t)ret_conv;
37943 }
37944
37945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37946         LDKChannelTransactionParameters obj_conv;
37947         obj_conv.inner = (void*)(obj & (~1));
37948         obj_conv.is_owned = false;
37949         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37950         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
37951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37953         CVec_u8Z_free(ret_var);
37954         return ret_arr;
37955 }
37956
37957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37958         LDKu8slice ser_ref;
37959         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37960         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37961         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
37962         *ret_conv = ChannelTransactionParameters_read(ser_ref);
37963         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37964         return (int64_t)ret_conv;
37965 }
37966
37967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37968         LDKDirectedChannelTransactionParameters this_obj_conv;
37969         this_obj_conv.inner = (void*)(this_obj & (~1));
37970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37972         DirectedChannelTransactionParameters_free(this_obj_conv);
37973 }
37974
37975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37976         LDKDirectedChannelTransactionParameters this_arg_conv;
37977         this_arg_conv.inner = (void*)(this_arg & (~1));
37978         this_arg_conv.is_owned = false;
37979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37980         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
37981         int64_t ret_ref = 0;
37982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37985         ret_ref = (uintptr_t)ret_var.inner;
37986         if (ret_var.is_owned) {
37987                 ret_ref |= 1;
37988         }
37989         return ret_ref;
37990 }
37991
37992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37993         LDKDirectedChannelTransactionParameters this_arg_conv;
37994         this_arg_conv.inner = (void*)(this_arg & (~1));
37995         this_arg_conv.is_owned = false;
37996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37997         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
37998         int64_t ret_ref = 0;
37999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38002         ret_ref = (uintptr_t)ret_var.inner;
38003         if (ret_var.is_owned) {
38004                 ret_ref |= 1;
38005         }
38006         return ret_ref;
38007 }
38008
38009 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
38010         LDKDirectedChannelTransactionParameters this_arg_conv;
38011         this_arg_conv.inner = (void*)(this_arg & (~1));
38012         this_arg_conv.is_owned = false;
38013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38014         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
38015         return ret_conv;
38016 }
38017
38018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
38019         LDKDirectedChannelTransactionParameters this_arg_conv;
38020         this_arg_conv.inner = (void*)(this_arg & (~1));
38021         this_arg_conv.is_owned = false;
38022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38023         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
38024         return ret_conv;
38025 }
38026
38027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
38028         LDKDirectedChannelTransactionParameters this_arg_conv;
38029         this_arg_conv.inner = (void*)(this_arg & (~1));
38030         this_arg_conv.is_owned = false;
38031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38032         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
38033         int64_t ret_ref = 0;
38034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38037         ret_ref = (uintptr_t)ret_var.inner;
38038         if (ret_var.is_owned) {
38039                 ret_ref |= 1;
38040         }
38041         return ret_ref;
38042 }
38043
38044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38045         LDKDirectedChannelTransactionParameters this_arg_conv;
38046         this_arg_conv.inner = (void*)(this_arg & (~1));
38047         this_arg_conv.is_owned = false;
38048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38049         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
38050         return ret_conv;
38051 }
38052
38053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38054         LDKHolderCommitmentTransaction this_obj_conv;
38055         this_obj_conv.inner = (void*)(this_obj & (~1));
38056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38058         HolderCommitmentTransaction_free(this_obj_conv);
38059 }
38060
38061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
38062         LDKHolderCommitmentTransaction this_ptr_conv;
38063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38064         this_ptr_conv.is_owned = false;
38065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38066         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
38068         return ret_arr;
38069 }
38070
38071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38072         LDKHolderCommitmentTransaction this_ptr_conv;
38073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38074         this_ptr_conv.is_owned = false;
38075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38076         LDKSignature val_ref;
38077         CHECK((*env)->GetArrayLength(env, val) == 64);
38078         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38079         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
38080 }
38081
38082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
38083         LDKHolderCommitmentTransaction this_ptr_conv;
38084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38085         this_ptr_conv.is_owned = false;
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38087         LDKCVec_SignatureZ val_constr;
38088         val_constr.datalen = (*env)->GetArrayLength(env, val);
38089         if (val_constr.datalen > 0)
38090                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38091         else
38092                 val_constr.data = NULL;
38093         for (size_t i = 0; i < val_constr.datalen; i++) {
38094                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
38095                 LDKSignature val_conv_8_ref;
38096                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
38097                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
38098                 val_constr.data[i] = val_conv_8_ref;
38099         }
38100         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
38101 }
38102
38103 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
38104         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
38105 int64_t ret_ref = 0;
38106 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38107 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38108 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38109 ret_ref = (uintptr_t)ret_var.inner;
38110 if (ret_var.is_owned) {
38111         ret_ref |= 1;
38112 }
38113         return ret_ref;
38114 }
38115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38116         LDKHolderCommitmentTransaction arg_conv;
38117         arg_conv.inner = (void*)(arg & (~1));
38118         arg_conv.is_owned = false;
38119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38120         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
38121         return ret_conv;
38122 }
38123
38124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38125         LDKHolderCommitmentTransaction orig_conv;
38126         orig_conv.inner = (void*)(orig & (~1));
38127         orig_conv.is_owned = false;
38128         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38129         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
38130         int64_t ret_ref = 0;
38131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38134         ret_ref = (uintptr_t)ret_var.inner;
38135         if (ret_var.is_owned) {
38136                 ret_ref |= 1;
38137         }
38138         return ret_ref;
38139 }
38140
38141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38142         LDKHolderCommitmentTransaction obj_conv;
38143         obj_conv.inner = (void*)(obj & (~1));
38144         obj_conv.is_owned = false;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38146         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
38147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38149         CVec_u8Z_free(ret_var);
38150         return ret_arr;
38151 }
38152
38153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38154         LDKu8slice ser_ref;
38155         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38156         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38157         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
38158         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
38159         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38160         return (int64_t)ret_conv;
38161 }
38162
38163 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) {
38164         LDKCommitmentTransaction commitment_tx_conv;
38165         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
38166         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
38167         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
38168         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
38169         LDKSignature counterparty_sig_ref;
38170         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
38171         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
38172         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
38173         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
38174         if (counterparty_htlc_sigs_constr.datalen > 0)
38175                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38176         else
38177                 counterparty_htlc_sigs_constr.data = NULL;
38178         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
38179                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
38180                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
38181                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
38182                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
38183                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
38184         }
38185         LDKPublicKey holder_funding_key_ref;
38186         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
38187         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
38188         LDKPublicKey counterparty_funding_key_ref;
38189         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
38190         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
38191         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
38192         int64_t ret_ref = 0;
38193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38196         ret_ref = (uintptr_t)ret_var.inner;
38197         if (ret_var.is_owned) {
38198                 ret_ref |= 1;
38199         }
38200         return ret_ref;
38201 }
38202
38203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38204         LDKBuiltCommitmentTransaction this_obj_conv;
38205         this_obj_conv.inner = (void*)(this_obj & (~1));
38206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38208         BuiltCommitmentTransaction_free(this_obj_conv);
38209 }
38210
38211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
38212         LDKBuiltCommitmentTransaction this_ptr_conv;
38213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38214         this_ptr_conv.is_owned = false;
38215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38216         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
38217         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38218         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38219         Transaction_free(ret_var);
38220         return ret_arr;
38221 }
38222
38223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38224         LDKBuiltCommitmentTransaction this_ptr_conv;
38225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38226         this_ptr_conv.is_owned = false;
38227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38228         LDKTransaction val_ref;
38229         val_ref.datalen = (*env)->GetArrayLength(env, val);
38230         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
38231         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38232         val_ref.data_is_owned = true;
38233         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
38234 }
38235
38236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
38237         LDKBuiltCommitmentTransaction this_ptr_conv;
38238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38239         this_ptr_conv.is_owned = false;
38240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
38243         return ret_arr;
38244 }
38245
38246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38247         LDKBuiltCommitmentTransaction this_ptr_conv;
38248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38249         this_ptr_conv.is_owned = false;
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38251         LDKThirtyTwoBytes val_ref;
38252         CHECK((*env)->GetArrayLength(env, val) == 32);
38253         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38254         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
38255 }
38256
38257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
38258         LDKTransaction transaction_arg_ref;
38259         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
38260         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
38261         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
38262         transaction_arg_ref.data_is_owned = true;
38263         LDKThirtyTwoBytes txid_arg_ref;
38264         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
38265         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
38266         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
38267         int64_t ret_ref = 0;
38268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38271         ret_ref = (uintptr_t)ret_var.inner;
38272         if (ret_var.is_owned) {
38273                 ret_ref |= 1;
38274         }
38275         return ret_ref;
38276 }
38277
38278 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
38279         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
38280 int64_t ret_ref = 0;
38281 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38282 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38283 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38284 ret_ref = (uintptr_t)ret_var.inner;
38285 if (ret_var.is_owned) {
38286         ret_ref |= 1;
38287 }
38288         return ret_ref;
38289 }
38290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38291         LDKBuiltCommitmentTransaction arg_conv;
38292         arg_conv.inner = (void*)(arg & (~1));
38293         arg_conv.is_owned = false;
38294         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38295         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
38296         return ret_conv;
38297 }
38298
38299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38300         LDKBuiltCommitmentTransaction orig_conv;
38301         orig_conv.inner = (void*)(orig & (~1));
38302         orig_conv.is_owned = false;
38303         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38304         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
38305         int64_t ret_ref = 0;
38306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38309         ret_ref = (uintptr_t)ret_var.inner;
38310         if (ret_var.is_owned) {
38311                 ret_ref |= 1;
38312         }
38313         return ret_ref;
38314 }
38315
38316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38317         LDKBuiltCommitmentTransaction obj_conv;
38318         obj_conv.inner = (void*)(obj & (~1));
38319         obj_conv.is_owned = false;
38320         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38321         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
38322         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38323         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38324         CVec_u8Z_free(ret_var);
38325         return ret_arr;
38326 }
38327
38328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38329         LDKu8slice ser_ref;
38330         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38331         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38332         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
38333         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
38334         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38335         return (int64_t)ret_conv;
38336 }
38337
38338 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) {
38339         LDKBuiltCommitmentTransaction this_arg_conv;
38340         this_arg_conv.inner = (void*)(this_arg & (~1));
38341         this_arg_conv.is_owned = false;
38342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38343         LDKu8slice funding_redeemscript_ref;
38344         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38345         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38346         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38347         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38348         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38349         return ret_arr;
38350 }
38351
38352 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) {
38353         LDKBuiltCommitmentTransaction this_arg_conv;
38354         this_arg_conv.inner = (void*)(this_arg & (~1));
38355         this_arg_conv.is_owned = false;
38356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38357         unsigned char funding_key_arr[32];
38358         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38359         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38360         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38361         LDKu8slice funding_redeemscript_ref;
38362         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38363         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38364         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38366         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38367         return ret_arr;
38368 }
38369
38370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38371         LDKClosingTransaction this_obj_conv;
38372         this_obj_conv.inner = (void*)(this_obj & (~1));
38373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38375         ClosingTransaction_free(this_obj_conv);
38376 }
38377
38378 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
38379         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
38380 int64_t ret_ref = 0;
38381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38384 ret_ref = (uintptr_t)ret_var.inner;
38385 if (ret_var.is_owned) {
38386         ret_ref |= 1;
38387 }
38388         return ret_ref;
38389 }
38390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38391         LDKClosingTransaction arg_conv;
38392         arg_conv.inner = (void*)(arg & (~1));
38393         arg_conv.is_owned = false;
38394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38395         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
38396         return ret_conv;
38397 }
38398
38399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38400         LDKClosingTransaction orig_conv;
38401         orig_conv.inner = (void*)(orig & (~1));
38402         orig_conv.is_owned = false;
38403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38404         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
38405         int64_t ret_ref = 0;
38406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38409         ret_ref = (uintptr_t)ret_var.inner;
38410         if (ret_var.is_owned) {
38411                 ret_ref |= 1;
38412         }
38413         return ret_ref;
38414 }
38415
38416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
38417         LDKClosingTransaction o_conv;
38418         o_conv.inner = (void*)(o & (~1));
38419         o_conv.is_owned = false;
38420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38421         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
38422         return ret_conv;
38423 }
38424
38425 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) {
38426         LDKCVec_u8Z to_holder_script_ref;
38427         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38428         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38429         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38430         LDKCVec_u8Z to_counterparty_script_ref;
38431         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38432         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38433         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38434         LDKOutPoint funding_outpoint_conv;
38435         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38436         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38437         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38438         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38439         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
38440         int64_t ret_ref = 0;
38441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38442         CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
38445         if (ret_var.is_owned) {
38446                 ret_ref |= 1;
38447         }
38448         return ret_ref;
38449 }
38450
38451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38452         LDKClosingTransaction this_arg_conv;
38453         this_arg_conv.inner = (void*)(this_arg & (~1));
38454         this_arg_conv.is_owned = false;
38455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38456         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
38457         int64_t ret_ref = 0;
38458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38461         ret_ref = (uintptr_t)ret_var.inner;
38462         if (ret_var.is_owned) {
38463                 ret_ref |= 1;
38464         }
38465         return ret_ref;
38466 }
38467
38468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
38469         LDKClosingTransaction this_arg_conv;
38470         this_arg_conv.inner = (void*)(this_arg & (~1));
38471         this_arg_conv.is_owned = false;
38472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38473         LDKOutPoint funding_outpoint_conv;
38474         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38475         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38477         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38478         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
38479         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
38480         return (int64_t)ret_conv;
38481 }
38482
38483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38484         LDKClosingTransaction this_arg_conv;
38485         this_arg_conv.inner = (void*)(this_arg & (~1));
38486         this_arg_conv.is_owned = false;
38487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38488         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
38489         return ret_conv;
38490 }
38491
38492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38493         LDKClosingTransaction this_arg_conv;
38494         this_arg_conv.inner = (void*)(this_arg & (~1));
38495         this_arg_conv.is_owned = false;
38496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38497         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
38498         return ret_conv;
38499 }
38500
38501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38502         LDKClosingTransaction this_arg_conv;
38503         this_arg_conv.inner = (void*)(this_arg & (~1));
38504         this_arg_conv.is_owned = false;
38505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38506         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
38507         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38508         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38509         return ret_arr;
38510 }
38511
38512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38513         LDKClosingTransaction this_arg_conv;
38514         this_arg_conv.inner = (void*)(this_arg & (~1));
38515         this_arg_conv.is_owned = false;
38516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38517         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
38518         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38519         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38520         return ret_arr;
38521 }
38522
38523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38524         LDKTrustedClosingTransaction this_obj_conv;
38525         this_obj_conv.inner = (void*)(this_obj & (~1));
38526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38528         TrustedClosingTransaction_free(this_obj_conv);
38529 }
38530
38531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38532         LDKTrustedClosingTransaction this_arg_conv;
38533         this_arg_conv.inner = (void*)(this_arg & (~1));
38534         this_arg_conv.is_owned = false;
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38536         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
38537         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38538         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38539         Transaction_free(ret_var);
38540         return ret_arr;
38541 }
38542
38543 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) {
38544         LDKTrustedClosingTransaction this_arg_conv;
38545         this_arg_conv.inner = (void*)(this_arg & (~1));
38546         this_arg_conv.is_owned = false;
38547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38548         LDKu8slice funding_redeemscript_ref;
38549         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38550         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38551         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38552         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38553         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38554         return ret_arr;
38555 }
38556
38557 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) {
38558         LDKTrustedClosingTransaction this_arg_conv;
38559         this_arg_conv.inner = (void*)(this_arg & (~1));
38560         this_arg_conv.is_owned = false;
38561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38562         unsigned char funding_key_arr[32];
38563         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38564         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38565         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38566         LDKu8slice funding_redeemscript_ref;
38567         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38568         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38569         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38571         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38572         return ret_arr;
38573 }
38574
38575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38576         LDKCommitmentTransaction this_obj_conv;
38577         this_obj_conv.inner = (void*)(this_obj & (~1));
38578         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38580         CommitmentTransaction_free(this_obj_conv);
38581 }
38582
38583 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
38584         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
38585 int64_t ret_ref = 0;
38586 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38587 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38588 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38589 ret_ref = (uintptr_t)ret_var.inner;
38590 if (ret_var.is_owned) {
38591         ret_ref |= 1;
38592 }
38593         return ret_ref;
38594 }
38595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38596         LDKCommitmentTransaction arg_conv;
38597         arg_conv.inner = (void*)(arg & (~1));
38598         arg_conv.is_owned = false;
38599         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38600         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
38601         return ret_conv;
38602 }
38603
38604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38605         LDKCommitmentTransaction orig_conv;
38606         orig_conv.inner = (void*)(orig & (~1));
38607         orig_conv.is_owned = false;
38608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38609         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
38610         int64_t ret_ref = 0;
38611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38614         ret_ref = (uintptr_t)ret_var.inner;
38615         if (ret_var.is_owned) {
38616                 ret_ref |= 1;
38617         }
38618         return ret_ref;
38619 }
38620
38621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38622         LDKCommitmentTransaction obj_conv;
38623         obj_conv.inner = (void*)(obj & (~1));
38624         obj_conv.is_owned = false;
38625         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38626         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
38627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38629         CVec_u8Z_free(ret_var);
38630         return ret_arr;
38631 }
38632
38633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38634         LDKu8slice ser_ref;
38635         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38636         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38637         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
38638         *ret_conv = CommitmentTransaction_read(ser_ref);
38639         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38640         return (int64_t)ret_conv;
38641 }
38642
38643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
38644         LDKCommitmentTransaction this_arg_conv;
38645         this_arg_conv.inner = (void*)(this_arg & (~1));
38646         this_arg_conv.is_owned = false;
38647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38648         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
38649         return ret_conv;
38650 }
38651
38652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38653         LDKCommitmentTransaction this_arg_conv;
38654         this_arg_conv.inner = (void*)(this_arg & (~1));
38655         this_arg_conv.is_owned = false;
38656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38657         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
38658         return ret_conv;
38659 }
38660
38661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38662         LDKCommitmentTransaction this_arg_conv;
38663         this_arg_conv.inner = (void*)(this_arg & (~1));
38664         this_arg_conv.is_owned = false;
38665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38666         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
38667         return ret_conv;
38668 }
38669
38670 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
38671         LDKCommitmentTransaction this_arg_conv;
38672         this_arg_conv.inner = (void*)(this_arg & (~1));
38673         this_arg_conv.is_owned = false;
38674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38675         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
38676         return ret_conv;
38677 }
38678
38679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38680         LDKCommitmentTransaction this_arg_conv;
38681         this_arg_conv.inner = (void*)(this_arg & (~1));
38682         this_arg_conv.is_owned = false;
38683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38684         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
38685         int64_t ret_ref = 0;
38686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38689         ret_ref = (uintptr_t)ret_var.inner;
38690         if (ret_var.is_owned) {
38691                 ret_ref |= 1;
38692         }
38693         return ret_ref;
38694 }
38695
38696 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) {
38697         LDKCommitmentTransaction this_arg_conv;
38698         this_arg_conv.inner = (void*)(this_arg & (~1));
38699         this_arg_conv.is_owned = false;
38700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38701         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38702         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38703         channel_parameters_conv.is_owned = false;
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38705         LDKChannelPublicKeys broadcaster_keys_conv;
38706         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38707         broadcaster_keys_conv.is_owned = false;
38708         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38709         LDKChannelPublicKeys countersignatory_keys_conv;
38710         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38711         countersignatory_keys_conv.is_owned = false;
38712         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38713         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
38714         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
38715         return (int64_t)ret_conv;
38716 }
38717
38718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38719         LDKTrustedCommitmentTransaction this_obj_conv;
38720         this_obj_conv.inner = (void*)(this_obj & (~1));
38721         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38723         TrustedCommitmentTransaction_free(this_obj_conv);
38724 }
38725
38726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
38727         LDKTrustedCommitmentTransaction this_arg_conv;
38728         this_arg_conv.inner = (void*)(this_arg & (~1));
38729         this_arg_conv.is_owned = false;
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38731         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38732         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
38733         return ret_arr;
38734 }
38735
38736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38737         LDKTrustedCommitmentTransaction this_arg_conv;
38738         this_arg_conv.inner = (void*)(this_arg & (~1));
38739         this_arg_conv.is_owned = false;
38740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38741         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
38742         int64_t ret_ref = 0;
38743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38746         ret_ref = (uintptr_t)ret_var.inner;
38747         if (ret_var.is_owned) {
38748                 ret_ref |= 1;
38749         }
38750         return ret_ref;
38751 }
38752
38753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
38754         LDKTrustedCommitmentTransaction this_arg_conv;
38755         this_arg_conv.inner = (void*)(this_arg & (~1));
38756         this_arg_conv.is_owned = false;
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38758         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
38759         int64_t ret_ref = 0;
38760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38763         ret_ref = (uintptr_t)ret_var.inner;
38764         if (ret_var.is_owned) {
38765                 ret_ref |= 1;
38766         }
38767         return ret_ref;
38768 }
38769
38770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38771         LDKTrustedCommitmentTransaction this_arg_conv;
38772         this_arg_conv.inner = (void*)(this_arg & (~1));
38773         this_arg_conv.is_owned = false;
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38775         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
38776         return ret_conv;
38777 }
38778
38779 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) {
38780         LDKTrustedCommitmentTransaction this_arg_conv;
38781         this_arg_conv.inner = (void*)(this_arg & (~1));
38782         this_arg_conv.is_owned = false;
38783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38784         unsigned char htlc_base_key_arr[32];
38785         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
38786         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
38787         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
38788         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38789         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38790         channel_parameters_conv.is_owned = false;
38791         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38792         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
38793         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
38794         return (int64_t)ret_conv;
38795 }
38796
38797 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) {
38798         LDKPublicKey broadcaster_payment_basepoint_ref;
38799         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
38800         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
38801         LDKPublicKey countersignatory_payment_basepoint_ref;
38802         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
38803         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
38804         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
38805         return ret_conv;
38806 }
38807
38808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38809         LDKInitFeatures a_conv;
38810         a_conv.inner = (void*)(a & (~1));
38811         a_conv.is_owned = false;
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38813         LDKInitFeatures b_conv;
38814         b_conv.inner = (void*)(b & (~1));
38815         b_conv.is_owned = false;
38816         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38817         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
38818         return ret_conv;
38819 }
38820
38821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38822         LDKNodeFeatures a_conv;
38823         a_conv.inner = (void*)(a & (~1));
38824         a_conv.is_owned = false;
38825         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38826         LDKNodeFeatures b_conv;
38827         b_conv.inner = (void*)(b & (~1));
38828         b_conv.is_owned = false;
38829         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38830         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
38831         return ret_conv;
38832 }
38833
38834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38835         LDKChannelFeatures a_conv;
38836         a_conv.inner = (void*)(a & (~1));
38837         a_conv.is_owned = false;
38838         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38839         LDKChannelFeatures b_conv;
38840         b_conv.inner = (void*)(b & (~1));
38841         b_conv.is_owned = false;
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38843         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
38844         return ret_conv;
38845 }
38846
38847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38848         LDKInvoiceFeatures a_conv;
38849         a_conv.inner = (void*)(a & (~1));
38850         a_conv.is_owned = false;
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38852         LDKInvoiceFeatures b_conv;
38853         b_conv.inner = (void*)(b & (~1));
38854         b_conv.is_owned = false;
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38856         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
38857         return ret_conv;
38858 }
38859
38860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38861         LDKChannelTypeFeatures a_conv;
38862         a_conv.inner = (void*)(a & (~1));
38863         a_conv.is_owned = false;
38864         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38865         LDKChannelTypeFeatures b_conv;
38866         b_conv.inner = (void*)(b & (~1));
38867         b_conv.is_owned = false;
38868         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38869         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
38870         return ret_conv;
38871 }
38872
38873 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
38874         LDKInitFeatures ret_var = InitFeatures_clone(arg);
38875 int64_t ret_ref = 0;
38876 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38877 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38878 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38879 ret_ref = (uintptr_t)ret_var.inner;
38880 if (ret_var.is_owned) {
38881         ret_ref |= 1;
38882 }
38883         return ret_ref;
38884 }
38885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38886         LDKInitFeatures arg_conv;
38887         arg_conv.inner = (void*)(arg & (~1));
38888         arg_conv.is_owned = false;
38889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38890         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
38891         return ret_conv;
38892 }
38893
38894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38895         LDKInitFeatures orig_conv;
38896         orig_conv.inner = (void*)(orig & (~1));
38897         orig_conv.is_owned = false;
38898         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38899         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
38900         int64_t ret_ref = 0;
38901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38904         ret_ref = (uintptr_t)ret_var.inner;
38905         if (ret_var.is_owned) {
38906                 ret_ref |= 1;
38907         }
38908         return ret_ref;
38909 }
38910
38911 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
38912         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
38913 int64_t ret_ref = 0;
38914 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38915 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38916 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38917 ret_ref = (uintptr_t)ret_var.inner;
38918 if (ret_var.is_owned) {
38919         ret_ref |= 1;
38920 }
38921         return ret_ref;
38922 }
38923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38924         LDKNodeFeatures arg_conv;
38925         arg_conv.inner = (void*)(arg & (~1));
38926         arg_conv.is_owned = false;
38927         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38928         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
38929         return ret_conv;
38930 }
38931
38932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38933         LDKNodeFeatures orig_conv;
38934         orig_conv.inner = (void*)(orig & (~1));
38935         orig_conv.is_owned = false;
38936         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38937         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
38938         int64_t ret_ref = 0;
38939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38942         ret_ref = (uintptr_t)ret_var.inner;
38943         if (ret_var.is_owned) {
38944                 ret_ref |= 1;
38945         }
38946         return ret_ref;
38947 }
38948
38949 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
38950         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
38951 int64_t ret_ref = 0;
38952 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38953 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38954 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38955 ret_ref = (uintptr_t)ret_var.inner;
38956 if (ret_var.is_owned) {
38957         ret_ref |= 1;
38958 }
38959         return ret_ref;
38960 }
38961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38962         LDKChannelFeatures arg_conv;
38963         arg_conv.inner = (void*)(arg & (~1));
38964         arg_conv.is_owned = false;
38965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38966         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
38967         return ret_conv;
38968 }
38969
38970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38971         LDKChannelFeatures orig_conv;
38972         orig_conv.inner = (void*)(orig & (~1));
38973         orig_conv.is_owned = false;
38974         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38975         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
38976         int64_t ret_ref = 0;
38977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38980         ret_ref = (uintptr_t)ret_var.inner;
38981         if (ret_var.is_owned) {
38982                 ret_ref |= 1;
38983         }
38984         return ret_ref;
38985 }
38986
38987 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
38988         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
38989 int64_t ret_ref = 0;
38990 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38991 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38993 ret_ref = (uintptr_t)ret_var.inner;
38994 if (ret_var.is_owned) {
38995         ret_ref |= 1;
38996 }
38997         return ret_ref;
38998 }
38999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39000         LDKInvoiceFeatures arg_conv;
39001         arg_conv.inner = (void*)(arg & (~1));
39002         arg_conv.is_owned = false;
39003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39004         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
39005         return ret_conv;
39006 }
39007
39008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39009         LDKInvoiceFeatures orig_conv;
39010         orig_conv.inner = (void*)(orig & (~1));
39011         orig_conv.is_owned = false;
39012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39013         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
39014         int64_t ret_ref = 0;
39015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39018         ret_ref = (uintptr_t)ret_var.inner;
39019         if (ret_var.is_owned) {
39020                 ret_ref |= 1;
39021         }
39022         return ret_ref;
39023 }
39024
39025 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
39026         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
39027 int64_t ret_ref = 0;
39028 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39029 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39030 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39031 ret_ref = (uintptr_t)ret_var.inner;
39032 if (ret_var.is_owned) {
39033         ret_ref |= 1;
39034 }
39035         return ret_ref;
39036 }
39037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39038         LDKChannelTypeFeatures arg_conv;
39039         arg_conv.inner = (void*)(arg & (~1));
39040         arg_conv.is_owned = false;
39041         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39042         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
39043         return ret_conv;
39044 }
39045
39046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39047         LDKChannelTypeFeatures orig_conv;
39048         orig_conv.inner = (void*)(orig & (~1));
39049         orig_conv.is_owned = false;
39050         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39051         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
39052         int64_t ret_ref = 0;
39053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39056         ret_ref = (uintptr_t)ret_var.inner;
39057         if (ret_var.is_owned) {
39058                 ret_ref |= 1;
39059         }
39060         return ret_ref;
39061 }
39062
39063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39064         LDKInitFeatures this_obj_conv;
39065         this_obj_conv.inner = (void*)(this_obj & (~1));
39066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39068         InitFeatures_free(this_obj_conv);
39069 }
39070
39071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39072         LDKNodeFeatures this_obj_conv;
39073         this_obj_conv.inner = (void*)(this_obj & (~1));
39074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39076         NodeFeatures_free(this_obj_conv);
39077 }
39078
39079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39080         LDKChannelFeatures this_obj_conv;
39081         this_obj_conv.inner = (void*)(this_obj & (~1));
39082         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39084         ChannelFeatures_free(this_obj_conv);
39085 }
39086
39087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39088         LDKInvoiceFeatures this_obj_conv;
39089         this_obj_conv.inner = (void*)(this_obj & (~1));
39090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39092         InvoiceFeatures_free(this_obj_conv);
39093 }
39094
39095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39096         LDKChannelTypeFeatures this_obj_conv;
39097         this_obj_conv.inner = (void*)(this_obj & (~1));
39098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39100         ChannelTypeFeatures_free(this_obj_conv);
39101 }
39102
39103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
39104         LDKInitFeatures ret_var = InitFeatures_empty();
39105         int64_t ret_ref = 0;
39106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39109         ret_ref = (uintptr_t)ret_var.inner;
39110         if (ret_var.is_owned) {
39111                 ret_ref |= 1;
39112         }
39113         return ret_ref;
39114 }
39115
39116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
39117         LDKInitFeatures ret_var = InitFeatures_known();
39118         int64_t ret_ref = 0;
39119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39122         ret_ref = (uintptr_t)ret_var.inner;
39123         if (ret_var.is_owned) {
39124                 ret_ref |= 1;
39125         }
39126         return ret_ref;
39127 }
39128
39129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39130         LDKInitFeatures this_arg_conv;
39131         this_arg_conv.inner = (void*)(this_arg & (~1));
39132         this_arg_conv.is_owned = false;
39133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39134         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
39135         return ret_conv;
39136 }
39137
39138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
39139         LDKNodeFeatures ret_var = NodeFeatures_empty();
39140         int64_t ret_ref = 0;
39141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39144         ret_ref = (uintptr_t)ret_var.inner;
39145         if (ret_var.is_owned) {
39146                 ret_ref |= 1;
39147         }
39148         return ret_ref;
39149 }
39150
39151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
39152         LDKNodeFeatures ret_var = NodeFeatures_known();
39153         int64_t ret_ref = 0;
39154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39157         ret_ref = (uintptr_t)ret_var.inner;
39158         if (ret_var.is_owned) {
39159                 ret_ref |= 1;
39160         }
39161         return ret_ref;
39162 }
39163
39164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39165         LDKNodeFeatures this_arg_conv;
39166         this_arg_conv.inner = (void*)(this_arg & (~1));
39167         this_arg_conv.is_owned = false;
39168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39169         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
39170         return ret_conv;
39171 }
39172
39173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
39174         LDKChannelFeatures ret_var = ChannelFeatures_empty();
39175         int64_t ret_ref = 0;
39176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39179         ret_ref = (uintptr_t)ret_var.inner;
39180         if (ret_var.is_owned) {
39181                 ret_ref |= 1;
39182         }
39183         return ret_ref;
39184 }
39185
39186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
39187         LDKChannelFeatures ret_var = ChannelFeatures_known();
39188         int64_t ret_ref = 0;
39189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39192         ret_ref = (uintptr_t)ret_var.inner;
39193         if (ret_var.is_owned) {
39194                 ret_ref |= 1;
39195         }
39196         return ret_ref;
39197 }
39198
39199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39200         LDKChannelFeatures this_arg_conv;
39201         this_arg_conv.inner = (void*)(this_arg & (~1));
39202         this_arg_conv.is_owned = false;
39203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39204         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
39205         return ret_conv;
39206 }
39207
39208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
39209         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
39210         int64_t ret_ref = 0;
39211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39214         ret_ref = (uintptr_t)ret_var.inner;
39215         if (ret_var.is_owned) {
39216                 ret_ref |= 1;
39217         }
39218         return ret_ref;
39219 }
39220
39221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
39222         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
39223         int64_t ret_ref = 0;
39224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39227         ret_ref = (uintptr_t)ret_var.inner;
39228         if (ret_var.is_owned) {
39229                 ret_ref |= 1;
39230         }
39231         return ret_ref;
39232 }
39233
39234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39235         LDKInvoiceFeatures this_arg_conv;
39236         this_arg_conv.inner = (void*)(this_arg & (~1));
39237         this_arg_conv.is_owned = false;
39238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39239         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
39240         return ret_conv;
39241 }
39242
39243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
39244         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
39245         int64_t ret_ref = 0;
39246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39249         ret_ref = (uintptr_t)ret_var.inner;
39250         if (ret_var.is_owned) {
39251                 ret_ref |= 1;
39252         }
39253         return ret_ref;
39254 }
39255
39256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
39257         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
39258         int64_t ret_ref = 0;
39259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39262         ret_ref = (uintptr_t)ret_var.inner;
39263         if (ret_var.is_owned) {
39264                 ret_ref |= 1;
39265         }
39266         return ret_ref;
39267 }
39268
39269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39270         LDKChannelTypeFeatures this_arg_conv;
39271         this_arg_conv.inner = (void*)(this_arg & (~1));
39272         this_arg_conv.is_owned = false;
39273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39274         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
39275         return ret_conv;
39276 }
39277
39278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39279         LDKInitFeatures obj_conv;
39280         obj_conv.inner = (void*)(obj & (~1));
39281         obj_conv.is_owned = false;
39282         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39283         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
39284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39286         CVec_u8Z_free(ret_var);
39287         return ret_arr;
39288 }
39289
39290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39291         LDKu8slice ser_ref;
39292         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39293         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39294         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
39295         *ret_conv = InitFeatures_read(ser_ref);
39296         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39297         return (int64_t)ret_conv;
39298 }
39299
39300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39301         LDKChannelFeatures obj_conv;
39302         obj_conv.inner = (void*)(obj & (~1));
39303         obj_conv.is_owned = false;
39304         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39305         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
39306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39308         CVec_u8Z_free(ret_var);
39309         return ret_arr;
39310 }
39311
39312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39313         LDKu8slice ser_ref;
39314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39316         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
39317         *ret_conv = ChannelFeatures_read(ser_ref);
39318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39319         return (int64_t)ret_conv;
39320 }
39321
39322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39323         LDKNodeFeatures obj_conv;
39324         obj_conv.inner = (void*)(obj & (~1));
39325         obj_conv.is_owned = false;
39326         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39327         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
39328         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39329         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39330         CVec_u8Z_free(ret_var);
39331         return ret_arr;
39332 }
39333
39334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39335         LDKu8slice ser_ref;
39336         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39337         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39338         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
39339         *ret_conv = NodeFeatures_read(ser_ref);
39340         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39341         return (int64_t)ret_conv;
39342 }
39343
39344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39345         LDKInvoiceFeatures obj_conv;
39346         obj_conv.inner = (void*)(obj & (~1));
39347         obj_conv.is_owned = false;
39348         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39349         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
39350         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39351         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39352         CVec_u8Z_free(ret_var);
39353         return ret_arr;
39354 }
39355
39356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39357         LDKu8slice ser_ref;
39358         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39359         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39360         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
39361         *ret_conv = InvoiceFeatures_read(ser_ref);
39362         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39363         return (int64_t)ret_conv;
39364 }
39365
39366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39367         LDKChannelTypeFeatures obj_conv;
39368         obj_conv.inner = (void*)(obj & (~1));
39369         obj_conv.is_owned = false;
39370         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39371         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
39372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39374         CVec_u8Z_free(ret_var);
39375         return ret_arr;
39376 }
39377
39378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39379         LDKu8slice ser_ref;
39380         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39381         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39382         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
39383         *ret_conv = ChannelTypeFeatures_read(ser_ref);
39384         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39385         return (int64_t)ret_conv;
39386 }
39387
39388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39389         LDKShutdownScript this_obj_conv;
39390         this_obj_conv.inner = (void*)(this_obj & (~1));
39391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39393         ShutdownScript_free(this_obj_conv);
39394 }
39395
39396 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
39397         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
39398 int64_t ret_ref = 0;
39399 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39400 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39401 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39402 ret_ref = (uintptr_t)ret_var.inner;
39403 if (ret_var.is_owned) {
39404         ret_ref |= 1;
39405 }
39406         return ret_ref;
39407 }
39408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39409         LDKShutdownScript arg_conv;
39410         arg_conv.inner = (void*)(arg & (~1));
39411         arg_conv.is_owned = false;
39412         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39413         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
39414         return ret_conv;
39415 }
39416
39417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39418         LDKShutdownScript orig_conv;
39419         orig_conv.inner = (void*)(orig & (~1));
39420         orig_conv.is_owned = false;
39421         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39422         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
39423         int64_t ret_ref = 0;
39424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39427         ret_ref = (uintptr_t)ret_var.inner;
39428         if (ret_var.is_owned) {
39429                 ret_ref |= 1;
39430         }
39431         return ret_ref;
39432 }
39433
39434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39435         LDKInvalidShutdownScript this_obj_conv;
39436         this_obj_conv.inner = (void*)(this_obj & (~1));
39437         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39439         InvalidShutdownScript_free(this_obj_conv);
39440 }
39441
39442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
39443         LDKInvalidShutdownScript this_ptr_conv;
39444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39445         this_ptr_conv.is_owned = false;
39446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39447         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
39448         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39449         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39450         return ret_arr;
39451 }
39452
39453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39454         LDKInvalidShutdownScript this_ptr_conv;
39455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39456         this_ptr_conv.is_owned = false;
39457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39458         LDKCVec_u8Z val_ref;
39459         val_ref.datalen = (*env)->GetArrayLength(env, val);
39460         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39461         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39462         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
39463 }
39464
39465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
39466         LDKCVec_u8Z script_arg_ref;
39467         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
39468         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39469         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
39470         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
39471         int64_t ret_ref = 0;
39472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39475         ret_ref = (uintptr_t)ret_var.inner;
39476         if (ret_var.is_owned) {
39477                 ret_ref |= 1;
39478         }
39479         return ret_ref;
39480 }
39481
39482 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
39483         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
39484 int64_t ret_ref = 0;
39485 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39486 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39487 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39488 ret_ref = (uintptr_t)ret_var.inner;
39489 if (ret_var.is_owned) {
39490         ret_ref |= 1;
39491 }
39492         return ret_ref;
39493 }
39494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39495         LDKInvalidShutdownScript arg_conv;
39496         arg_conv.inner = (void*)(arg & (~1));
39497         arg_conv.is_owned = false;
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39499         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
39500         return ret_conv;
39501 }
39502
39503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39504         LDKInvalidShutdownScript orig_conv;
39505         orig_conv.inner = (void*)(orig & (~1));
39506         orig_conv.is_owned = false;
39507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39508         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
39509         int64_t ret_ref = 0;
39510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39513         ret_ref = (uintptr_t)ret_var.inner;
39514         if (ret_var.is_owned) {
39515                 ret_ref |= 1;
39516         }
39517         return ret_ref;
39518 }
39519
39520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
39521         LDKShutdownScript obj_conv;
39522         obj_conv.inner = (void*)(obj & (~1));
39523         obj_conv.is_owned = false;
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39525         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
39526         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39527         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39528         CVec_u8Z_free(ret_var);
39529         return ret_arr;
39530 }
39531
39532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39533         LDKu8slice ser_ref;
39534         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39535         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39536         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
39537         *ret_conv = ShutdownScript_read(ser_ref);
39538         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39539         return (int64_t)ret_conv;
39540 }
39541
39542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
39543         unsigned char pubkey_hash_arr[20];
39544         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
39545         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
39546         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
39547         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
39548         int64_t ret_ref = 0;
39549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39552         ret_ref = (uintptr_t)ret_var.inner;
39553         if (ret_var.is_owned) {
39554                 ret_ref |= 1;
39555         }
39556         return ret_ref;
39557 }
39558
39559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
39560         unsigned char script_hash_arr[32];
39561         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
39562         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
39563         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
39564         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
39565         int64_t ret_ref = 0;
39566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39569         ret_ref = (uintptr_t)ret_var.inner;
39570         if (ret_var.is_owned) {
39571                 ret_ref |= 1;
39572         }
39573         return ret_ref;
39574 }
39575
39576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
39577         LDKu8slice program_ref;
39578         program_ref.datalen = (*env)->GetArrayLength(env, program);
39579         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
39580         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39581         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
39582         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
39583         return (int64_t)ret_conv;
39584 }
39585
39586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39587         LDKShutdownScript this_arg_conv;
39588         this_arg_conv.inner = (void*)(this_arg & (~1));
39589         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39591         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39592         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39593         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39594         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39595         CVec_u8Z_free(ret_var);
39596         return ret_arr;
39597 }
39598
39599 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
39600         LDKShutdownScript this_arg_conv;
39601         this_arg_conv.inner = (void*)(this_arg & (~1));
39602         this_arg_conv.is_owned = false;
39603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39604         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39605         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
39606         return ret_arr;
39607 }
39608
39609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
39610         LDKShutdownScript this_arg_conv;
39611         this_arg_conv.inner = (void*)(this_arg & (~1));
39612         this_arg_conv.is_owned = false;
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39614         LDKInitFeatures features_conv;
39615         features_conv.inner = (void*)(features & (~1));
39616         features_conv.is_owned = false;
39617         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39618         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39619         return ret_conv;
39620 }
39621
39622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39623         if ((this_ptr & 1) != 0) return;
39624         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39625         CHECK_ACCESS(this_ptr_ptr);
39626         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39627         FREE((void*)this_ptr);
39628         CustomMessageReader_free(this_ptr_conv);
39629 }
39630
39631 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39632         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39633         *ret_ret = Type_clone(arg);
39634         return (int64_t)ret_ret;
39635 }
39636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39637         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39638         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39639         LDKType* arg_conv = (LDKType*)arg_ptr;
39640         int64_t ret_conv = Type_clone_ptr(arg_conv);
39641         return ret_conv;
39642 }
39643
39644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39645         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39646         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39647         LDKType* orig_conv = (LDKType*)orig_ptr;
39648         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39649         *ret_ret = Type_clone(orig_conv);
39650         return (int64_t)ret_ret;
39651 }
39652
39653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39654         if ((this_ptr & 1) != 0) return;
39655         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39656         CHECK_ACCESS(this_ptr_ptr);
39657         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39658         FREE((void*)this_ptr);
39659         Type_free(this_ptr_conv);
39660 }
39661
39662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39663         LDKNodeId this_obj_conv;
39664         this_obj_conv.inner = (void*)(this_obj & (~1));
39665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39667         NodeId_free(this_obj_conv);
39668 }
39669
39670 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39671         LDKNodeId ret_var = NodeId_clone(arg);
39672 int64_t ret_ref = 0;
39673 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39674 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39675 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39676 ret_ref = (uintptr_t)ret_var.inner;
39677 if (ret_var.is_owned) {
39678         ret_ref |= 1;
39679 }
39680         return ret_ref;
39681 }
39682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39683         LDKNodeId arg_conv;
39684         arg_conv.inner = (void*)(arg & (~1));
39685         arg_conv.is_owned = false;
39686         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39687         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
39688         return ret_conv;
39689 }
39690
39691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39692         LDKNodeId orig_conv;
39693         orig_conv.inner = (void*)(orig & (~1));
39694         orig_conv.is_owned = false;
39695         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39696         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39697         int64_t ret_ref = 0;
39698         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39699         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39701         ret_ref = (uintptr_t)ret_var.inner;
39702         if (ret_var.is_owned) {
39703                 ret_ref |= 1;
39704         }
39705         return ret_ref;
39706 }
39707
39708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
39709         LDKPublicKey pubkey_ref;
39710         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
39711         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
39712         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39713         int64_t ret_ref = 0;
39714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39717         ret_ref = (uintptr_t)ret_var.inner;
39718         if (ret_var.is_owned) {
39719                 ret_ref |= 1;
39720         }
39721         return ret_ref;
39722 }
39723
39724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
39725         LDKNodeId this_arg_conv;
39726         this_arg_conv.inner = (void*)(this_arg & (~1));
39727         this_arg_conv.is_owned = false;
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39729         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39732         return ret_arr;
39733 }
39734
39735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
39736         LDKNodeId o_conv;
39737         o_conv.inner = (void*)(o & (~1));
39738         o_conv.is_owned = false;
39739         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39740         int64_t ret_conv = NodeId_hash(&o_conv);
39741         return ret_conv;
39742 }
39743
39744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
39745         LDKNodeId obj_conv;
39746         obj_conv.inner = (void*)(obj & (~1));
39747         obj_conv.is_owned = false;
39748         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39749         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39750         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39751         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39752         CVec_u8Z_free(ret_var);
39753         return ret_arr;
39754 }
39755
39756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39757         LDKu8slice ser_ref;
39758         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39759         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39760         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39761         *ret_conv = NodeId_read(ser_ref);
39762         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39763         return (int64_t)ret_conv;
39764 }
39765
39766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39767         LDKNetworkGraph this_obj_conv;
39768         this_obj_conv.inner = (void*)(this_obj & (~1));
39769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39771         NetworkGraph_free(this_obj_conv);
39772 }
39773
39774 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
39775         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
39776 int64_t ret_ref = 0;
39777 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39778 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39779 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39780 ret_ref = (uintptr_t)ret_var.inner;
39781 if (ret_var.is_owned) {
39782         ret_ref |= 1;
39783 }
39784         return ret_ref;
39785 }
39786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39787         LDKNetworkGraph arg_conv;
39788         arg_conv.inner = (void*)(arg & (~1));
39789         arg_conv.is_owned = false;
39790         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39791         int64_t ret_conv = NetworkGraph_clone_ptr(&arg_conv);
39792         return ret_conv;
39793 }
39794
39795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39796         LDKNetworkGraph orig_conv;
39797         orig_conv.inner = (void*)(orig & (~1));
39798         orig_conv.is_owned = false;
39799         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39800         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
39801         int64_t ret_ref = 0;
39802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39805         ret_ref = (uintptr_t)ret_var.inner;
39806         if (ret_var.is_owned) {
39807                 ret_ref |= 1;
39808         }
39809         return ret_ref;
39810 }
39811
39812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39813         LDKReadOnlyNetworkGraph this_obj_conv;
39814         this_obj_conv.inner = (void*)(this_obj & (~1));
39815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39817         ReadOnlyNetworkGraph_free(this_obj_conv);
39818 }
39819
39820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39821         if ((this_ptr & 1) != 0) return;
39822         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39823         CHECK_ACCESS(this_ptr_ptr);
39824         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39825         FREE((void*)this_ptr);
39826         NetworkUpdate_free(this_ptr_conv);
39827 }
39828
39829 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39830         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39831         *ret_copy = NetworkUpdate_clone(arg);
39832 int64_t ret_ref = (uintptr_t)ret_copy;
39833         return ret_ref;
39834 }
39835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39836         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39837         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
39838         return ret_conv;
39839 }
39840
39841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39842         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39843         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39844         *ret_copy = NetworkUpdate_clone(orig_conv);
39845         int64_t ret_ref = (uintptr_t)ret_copy;
39846         return ret_ref;
39847 }
39848
39849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
39850         LDKChannelUpdate msg_conv;
39851         msg_conv.inner = (void*)(msg & (~1));
39852         msg_conv.is_owned = (msg & 1) || (msg == 0);
39853         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39854         msg_conv = ChannelUpdate_clone(&msg_conv);
39855         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39856         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39857         int64_t ret_ref = (uintptr_t)ret_copy;
39858         return ret_ref;
39859 }
39860
39861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
39862         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39863         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
39864         int64_t ret_ref = (uintptr_t)ret_copy;
39865         return ret_ref;
39866 }
39867
39868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
39869         LDKPublicKey node_id_ref;
39870         CHECK((*env)->GetArrayLength(env, node_id) == 33);
39871         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
39872         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39873         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39874         int64_t ret_ref = (uintptr_t)ret_copy;
39875         return ret_ref;
39876 }
39877
39878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39879         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39880         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39883         CVec_u8Z_free(ret_var);
39884         return ret_arr;
39885 }
39886
39887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39888         LDKu8slice ser_ref;
39889         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39890         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39891         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39892         *ret_conv = NetworkUpdate_read(ser_ref);
39893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39894         return (int64_t)ret_conv;
39895 }
39896
39897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39898         LDKNetGraphMsgHandler this_arg_conv;
39899         this_arg_conv.inner = (void*)(this_arg & (~1));
39900         this_arg_conv.is_owned = false;
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39902         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39903         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
39904         return (int64_t)ret_ret;
39905 }
39906
39907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39908         LDKNetGraphMsgHandler this_obj_conv;
39909         this_obj_conv.inner = (void*)(this_obj & (~1));
39910         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39912         NetGraphMsgHandler_free(this_obj_conv);
39913 }
39914
39915 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) {
39916         LDKNetworkGraph network_graph_conv;
39917         network_graph_conv.inner = (void*)(network_graph & (~1));
39918         network_graph_conv.is_owned = false;
39919         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39920         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39921         CHECK_ACCESS(chain_access_ptr);
39922         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39923         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39924         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39925                 // Manually implement clone for Java trait instances
39926                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39927                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39928                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39929                 }
39930         }
39931         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39932         CHECK_ACCESS(logger_ptr);
39933         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39934         if (logger_conv.free == LDKLogger_JCalls_free) {
39935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39936                 LDKLogger_JCalls_cloned(&logger_conv);
39937         }
39938         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
39939         int64_t ret_ref = 0;
39940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39943         ret_ref = (uintptr_t)ret_var.inner;
39944         if (ret_var.is_owned) {
39945                 ret_ref |= 1;
39946         }
39947         return ret_ref;
39948 }
39949
39950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
39951         LDKNetGraphMsgHandler this_arg_conv;
39952         this_arg_conv.inner = (void*)(this_arg & (~1));
39953         this_arg_conv.is_owned = false;
39954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39955         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39956         CHECK_ACCESS(chain_access_ptr);
39957         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39958         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39959         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39960                 // Manually implement clone for Java trait instances
39961                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39962                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39963                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39964                 }
39965         }
39966         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
39967 }
39968
39969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39970         LDKNetGraphMsgHandler this_arg_conv;
39971         this_arg_conv.inner = (void*)(this_arg & (~1));
39972         this_arg_conv.is_owned = false;
39973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39974         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39975         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
39976         return (int64_t)ret_ret;
39977 }
39978
39979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39980         LDKNetGraphMsgHandler this_arg_conv;
39981         this_arg_conv.inner = (void*)(this_arg & (~1));
39982         this_arg_conv.is_owned = false;
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39984         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39985         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
39986         return (int64_t)ret_ret;
39987 }
39988
39989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39990         LDKChannelUpdateInfo this_obj_conv;
39991         this_obj_conv.inner = (void*)(this_obj & (~1));
39992         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39994         ChannelUpdateInfo_free(this_obj_conv);
39995 }
39996
39997 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
39998         LDKChannelUpdateInfo this_ptr_conv;
39999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40000         this_ptr_conv.is_owned = false;
40001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40002         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
40003         return ret_conv;
40004 }
40005
40006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40007         LDKChannelUpdateInfo this_ptr_conv;
40008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40009         this_ptr_conv.is_owned = false;
40010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40011         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
40012 }
40013
40014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
40015         LDKChannelUpdateInfo this_ptr_conv;
40016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40017         this_ptr_conv.is_owned = false;
40018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40019         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
40020         return ret_conv;
40021 }
40022
40023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40024         LDKChannelUpdateInfo this_ptr_conv;
40025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40026         this_ptr_conv.is_owned = false;
40027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40028         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
40029 }
40030
40031 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
40032         LDKChannelUpdateInfo this_ptr_conv;
40033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40034         this_ptr_conv.is_owned = false;
40035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40036         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
40037         return ret_conv;
40038 }
40039
40040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
40041         LDKChannelUpdateInfo this_ptr_conv;
40042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40043         this_ptr_conv.is_owned = false;
40044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40045         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
40046 }
40047
40048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40049         LDKChannelUpdateInfo this_ptr_conv;
40050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40051         this_ptr_conv.is_owned = false;
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40053         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
40054         return ret_conv;
40055 }
40056
40057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40058         LDKChannelUpdateInfo this_ptr_conv;
40059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40060         this_ptr_conv.is_owned = false;
40061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40062         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
40063 }
40064
40065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40066         LDKChannelUpdateInfo this_ptr_conv;
40067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40068         this_ptr_conv.is_owned = false;
40069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40070         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40071         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
40072         int64_t ret_ref = (uintptr_t)ret_copy;
40073         return ret_ref;
40074 }
40075
40076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40077         LDKChannelUpdateInfo this_ptr_conv;
40078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40079         this_ptr_conv.is_owned = false;
40080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40081         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40082         CHECK_ACCESS(val_ptr);
40083         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40084         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40085         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
40086 }
40087
40088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
40089         LDKChannelUpdateInfo this_ptr_conv;
40090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40091         this_ptr_conv.is_owned = false;
40092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40093         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
40094         int64_t ret_ref = 0;
40095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40098         ret_ref = (uintptr_t)ret_var.inner;
40099         if (ret_var.is_owned) {
40100                 ret_ref |= 1;
40101         }
40102         return ret_ref;
40103 }
40104
40105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40106         LDKChannelUpdateInfo this_ptr_conv;
40107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40108         this_ptr_conv.is_owned = false;
40109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40110         LDKRoutingFees val_conv;
40111         val_conv.inner = (void*)(val & (~1));
40112         val_conv.is_owned = (val & 1) || (val == 0);
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40114         val_conv = RoutingFees_clone(&val_conv);
40115         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
40116 }
40117
40118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40119         LDKChannelUpdateInfo this_ptr_conv;
40120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40121         this_ptr_conv.is_owned = false;
40122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40123         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
40124         int64_t ret_ref = 0;
40125         if ((uintptr_t)ret_var.inner > 4096) {
40126                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40127                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40129                 ret_ref = (uintptr_t)ret_var.inner;
40130                 if (ret_var.is_owned) {
40131                         ret_ref |= 1;
40132                 }
40133         }
40134         return ret_ref;
40135 }
40136
40137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40138         LDKChannelUpdateInfo this_ptr_conv;
40139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40140         this_ptr_conv.is_owned = false;
40141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40142         LDKChannelUpdate val_conv;
40143         val_conv.inner = (void*)(val & (~1));
40144         val_conv.is_owned = (val & 1) || (val == 0);
40145         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40146         val_conv = ChannelUpdate_clone(&val_conv);
40147         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
40148 }
40149
40150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1new(JNIEnv *env, jclass clz, int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) {
40151         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
40152         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
40153         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
40154         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
40155         LDKRoutingFees fees_arg_conv;
40156         fees_arg_conv.inner = (void*)(fees_arg & (~1));
40157         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
40158         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
40159         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
40160         LDKChannelUpdate last_update_message_arg_conv;
40161         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
40162         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
40164         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
40165         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
40166         int64_t ret_ref = 0;
40167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40170         ret_ref = (uintptr_t)ret_var.inner;
40171         if (ret_var.is_owned) {
40172                 ret_ref |= 1;
40173         }
40174         return ret_ref;
40175 }
40176
40177 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
40178         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
40179 int64_t ret_ref = 0;
40180 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40181 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40182 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40183 ret_ref = (uintptr_t)ret_var.inner;
40184 if (ret_var.is_owned) {
40185         ret_ref |= 1;
40186 }
40187         return ret_ref;
40188 }
40189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40190         LDKChannelUpdateInfo arg_conv;
40191         arg_conv.inner = (void*)(arg & (~1));
40192         arg_conv.is_owned = false;
40193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40194         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
40195         return ret_conv;
40196 }
40197
40198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40199         LDKChannelUpdateInfo orig_conv;
40200         orig_conv.inner = (void*)(orig & (~1));
40201         orig_conv.is_owned = false;
40202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40203         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
40204         int64_t ret_ref = 0;
40205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40208         ret_ref = (uintptr_t)ret_var.inner;
40209         if (ret_var.is_owned) {
40210                 ret_ref |= 1;
40211         }
40212         return ret_ref;
40213 }
40214
40215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40216         LDKChannelUpdateInfo obj_conv;
40217         obj_conv.inner = (void*)(obj & (~1));
40218         obj_conv.is_owned = false;
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40220         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
40221         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40222         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40223         CVec_u8Z_free(ret_var);
40224         return ret_arr;
40225 }
40226
40227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40228         LDKu8slice ser_ref;
40229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40231         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
40232         *ret_conv = ChannelUpdateInfo_read(ser_ref);
40233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40234         return (int64_t)ret_conv;
40235 }
40236
40237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40238         LDKChannelInfo this_obj_conv;
40239         this_obj_conv.inner = (void*)(this_obj & (~1));
40240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40242         ChannelInfo_free(this_obj_conv);
40243 }
40244
40245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40246         LDKChannelInfo this_ptr_conv;
40247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40248         this_ptr_conv.is_owned = false;
40249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40250         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
40251         int64_t ret_ref = 0;
40252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40253         CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
40256         if (ret_var.is_owned) {
40257                 ret_ref |= 1;
40258         }
40259         return ret_ref;
40260 }
40261
40262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40263         LDKChannelInfo this_ptr_conv;
40264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40265         this_ptr_conv.is_owned = false;
40266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40267         LDKChannelFeatures val_conv;
40268         val_conv.inner = (void*)(val & (~1));
40269         val_conv.is_owned = (val & 1) || (val == 0);
40270         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40271         val_conv = ChannelFeatures_clone(&val_conv);
40272         ChannelInfo_set_features(&this_ptr_conv, val_conv);
40273 }
40274
40275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
40276         LDKChannelInfo this_ptr_conv;
40277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40278         this_ptr_conv.is_owned = false;
40279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40280         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
40281         int64_t ret_ref = 0;
40282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40285         ret_ref = (uintptr_t)ret_var.inner;
40286         if (ret_var.is_owned) {
40287                 ret_ref |= 1;
40288         }
40289         return ret_ref;
40290 }
40291
40292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40293         LDKChannelInfo this_ptr_conv;
40294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40295         this_ptr_conv.is_owned = false;
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40297         LDKNodeId val_conv;
40298         val_conv.inner = (void*)(val & (~1));
40299         val_conv.is_owned = (val & 1) || (val == 0);
40300         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40301         val_conv = NodeId_clone(&val_conv);
40302         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
40303 }
40304
40305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
40306         LDKChannelInfo this_ptr_conv;
40307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40308         this_ptr_conv.is_owned = false;
40309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40310         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
40311         int64_t ret_ref = 0;
40312         if ((uintptr_t)ret_var.inner > 4096) {
40313                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40314                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40316                 ret_ref = (uintptr_t)ret_var.inner;
40317                 if (ret_var.is_owned) {
40318                         ret_ref |= 1;
40319                 }
40320         }
40321         return ret_ref;
40322 }
40323
40324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40325         LDKChannelInfo this_ptr_conv;
40326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40327         this_ptr_conv.is_owned = false;
40328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40329         LDKChannelUpdateInfo val_conv;
40330         val_conv.inner = (void*)(val & (~1));
40331         val_conv.is_owned = (val & 1) || (val == 0);
40332         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40333         val_conv = ChannelUpdateInfo_clone(&val_conv);
40334         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
40335 }
40336
40337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
40338         LDKChannelInfo this_ptr_conv;
40339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40340         this_ptr_conv.is_owned = false;
40341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40342         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
40343         int64_t ret_ref = 0;
40344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40347         ret_ref = (uintptr_t)ret_var.inner;
40348         if (ret_var.is_owned) {
40349                 ret_ref |= 1;
40350         }
40351         return ret_ref;
40352 }
40353
40354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40355         LDKChannelInfo this_ptr_conv;
40356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40357         this_ptr_conv.is_owned = false;
40358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40359         LDKNodeId val_conv;
40360         val_conv.inner = (void*)(val & (~1));
40361         val_conv.is_owned = (val & 1) || (val == 0);
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40363         val_conv = NodeId_clone(&val_conv);
40364         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
40365 }
40366
40367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
40368         LDKChannelInfo this_ptr_conv;
40369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40370         this_ptr_conv.is_owned = false;
40371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40372         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
40373         int64_t ret_ref = 0;
40374         if ((uintptr_t)ret_var.inner > 4096) {
40375                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40376                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40378                 ret_ref = (uintptr_t)ret_var.inner;
40379                 if (ret_var.is_owned) {
40380                         ret_ref |= 1;
40381                 }
40382         }
40383         return ret_ref;
40384 }
40385
40386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40387         LDKChannelInfo this_ptr_conv;
40388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40389         this_ptr_conv.is_owned = false;
40390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40391         LDKChannelUpdateInfo val_conv;
40392         val_conv.inner = (void*)(val & (~1));
40393         val_conv.is_owned = (val & 1) || (val == 0);
40394         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40395         val_conv = ChannelUpdateInfo_clone(&val_conv);
40396         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
40397 }
40398
40399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
40400         LDKChannelInfo this_ptr_conv;
40401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40402         this_ptr_conv.is_owned = false;
40403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40404         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40405         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
40406         int64_t ret_ref = (uintptr_t)ret_copy;
40407         return ret_ref;
40408 }
40409
40410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40411         LDKChannelInfo this_ptr_conv;
40412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40413         this_ptr_conv.is_owned = false;
40414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40415         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40416         CHECK_ACCESS(val_ptr);
40417         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40418         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40419         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
40420 }
40421
40422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40423         LDKChannelInfo this_ptr_conv;
40424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40425         this_ptr_conv.is_owned = false;
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40427         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
40428         int64_t ret_ref = 0;
40429         if ((uintptr_t)ret_var.inner > 4096) {
40430                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40431                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40433                 ret_ref = (uintptr_t)ret_var.inner;
40434                 if (ret_var.is_owned) {
40435                         ret_ref |= 1;
40436                 }
40437         }
40438         return ret_ref;
40439 }
40440
40441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40442         LDKChannelInfo this_ptr_conv;
40443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40444         this_ptr_conv.is_owned = false;
40445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40446         LDKChannelAnnouncement val_conv;
40447         val_conv.inner = (void*)(val & (~1));
40448         val_conv.is_owned = (val & 1) || (val == 0);
40449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40450         val_conv = ChannelAnnouncement_clone(&val_conv);
40451         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
40452 }
40453
40454 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
40455         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
40456 int64_t ret_ref = 0;
40457 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40458 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40459 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40460 ret_ref = (uintptr_t)ret_var.inner;
40461 if (ret_var.is_owned) {
40462         ret_ref |= 1;
40463 }
40464         return ret_ref;
40465 }
40466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40467         LDKChannelInfo arg_conv;
40468         arg_conv.inner = (void*)(arg & (~1));
40469         arg_conv.is_owned = false;
40470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40471         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
40472         return ret_conv;
40473 }
40474
40475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40476         LDKChannelInfo orig_conv;
40477         orig_conv.inner = (void*)(orig & (~1));
40478         orig_conv.is_owned = false;
40479         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40480         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
40481         int64_t ret_ref = 0;
40482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40485         ret_ref = (uintptr_t)ret_var.inner;
40486         if (ret_var.is_owned) {
40487                 ret_ref |= 1;
40488         }
40489         return ret_ref;
40490 }
40491
40492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40493         LDKChannelInfo obj_conv;
40494         obj_conv.inner = (void*)(obj & (~1));
40495         obj_conv.is_owned = false;
40496         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40497         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
40498         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40499         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40500         CVec_u8Z_free(ret_var);
40501         return ret_arr;
40502 }
40503
40504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40505         LDKu8slice ser_ref;
40506         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40507         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40508         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
40509         *ret_conv = ChannelInfo_read(ser_ref);
40510         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40511         return (int64_t)ret_conv;
40512 }
40513
40514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40515         LDKDirectedChannelInfo this_obj_conv;
40516         this_obj_conv.inner = (void*)(this_obj & (~1));
40517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40519         DirectedChannelInfo_free(this_obj_conv);
40520 }
40521
40522 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
40523         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
40524 int64_t ret_ref = 0;
40525 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40526 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40527 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40528 ret_ref = (uintptr_t)ret_var.inner;
40529 if (ret_var.is_owned) {
40530         ret_ref |= 1;
40531 }
40532         return ret_ref;
40533 }
40534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40535         LDKDirectedChannelInfo arg_conv;
40536         arg_conv.inner = (void*)(arg & (~1));
40537         arg_conv.is_owned = false;
40538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40539         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
40540         return ret_conv;
40541 }
40542
40543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40544         LDKDirectedChannelInfo orig_conv;
40545         orig_conv.inner = (void*)(orig & (~1));
40546         orig_conv.is_owned = false;
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40548         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
40549         int64_t ret_ref = 0;
40550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40553         ret_ref = (uintptr_t)ret_var.inner;
40554         if (ret_var.is_owned) {
40555                 ret_ref |= 1;
40556         }
40557         return ret_ref;
40558 }
40559
40560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
40561         LDKDirectedChannelInfo this_arg_conv;
40562         this_arg_conv.inner = (void*)(this_arg & (~1));
40563         this_arg_conv.is_owned = false;
40564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40565         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
40566         int64_t ret_ref = 0;
40567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40570         ret_ref = (uintptr_t)ret_var.inner;
40571         if (ret_var.is_owned) {
40572                 ret_ref |= 1;
40573         }
40574         return ret_ref;
40575 }
40576
40577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
40578         LDKDirectedChannelInfo this_arg_conv;
40579         this_arg_conv.inner = (void*)(this_arg & (~1));
40580         this_arg_conv.is_owned = false;
40581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40582         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40583         int64_t ret_ref = 0;
40584         if ((uintptr_t)ret_var.inner > 4096) {
40585                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40586                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40588                 ret_ref = (uintptr_t)ret_var.inner;
40589                 if (ret_var.is_owned) {
40590                         ret_ref |= 1;
40591                 }
40592         }
40593         return ret_ref;
40594 }
40595
40596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
40597         LDKDirectedChannelInfo this_arg_conv;
40598         this_arg_conv.inner = (void*)(this_arg & (~1));
40599         this_arg_conv.is_owned = false;
40600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40601         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40602         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40603         int64_t ret_ref = (uintptr_t)ret_copy;
40604         return ret_ref;
40605 }
40606
40607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40608         if ((this_ptr & 1) != 0) return;
40609         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40610         CHECK_ACCESS(this_ptr_ptr);
40611         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40612         FREE((void*)this_ptr);
40613         EffectiveCapacity_free(this_ptr_conv);
40614 }
40615
40616 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40617         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40618         *ret_copy = EffectiveCapacity_clone(arg);
40619 int64_t ret_ref = (uintptr_t)ret_copy;
40620         return ret_ref;
40621 }
40622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40623         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40624         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
40625         return ret_conv;
40626 }
40627
40628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40629         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40630         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40631         *ret_copy = EffectiveCapacity_clone(orig_conv);
40632         int64_t ret_ref = (uintptr_t)ret_copy;
40633         return ret_ref;
40634 }
40635
40636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
40637         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40638         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40639         int64_t ret_ref = (uintptr_t)ret_copy;
40640         return ret_ref;
40641 }
40642
40643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
40644         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40645         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40646         int64_t ret_ref = (uintptr_t)ret_copy;
40647         return ret_ref;
40648 }
40649
40650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat) {
40651         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40652         *ret_copy = EffectiveCapacity_total(capacity_msat);
40653         int64_t ret_ref = (uintptr_t)ret_copy;
40654         return ret_ref;
40655 }
40656
40657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
40658         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40659         *ret_copy = EffectiveCapacity_infinite();
40660         int64_t ret_ref = (uintptr_t)ret_copy;
40661         return ret_ref;
40662 }
40663
40664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
40665         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40666         *ret_copy = EffectiveCapacity_unknown();
40667         int64_t ret_ref = (uintptr_t)ret_copy;
40668         return ret_ref;
40669 }
40670
40671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
40672         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40673         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
40674         return ret_conv;
40675 }
40676
40677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40678         LDKRoutingFees this_obj_conv;
40679         this_obj_conv.inner = (void*)(this_obj & (~1));
40680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40682         RoutingFees_free(this_obj_conv);
40683 }
40684
40685 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40686         LDKRoutingFees this_ptr_conv;
40687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40688         this_ptr_conv.is_owned = false;
40689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40690         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
40691         return ret_conv;
40692 }
40693
40694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40695         LDKRoutingFees this_ptr_conv;
40696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40697         this_ptr_conv.is_owned = false;
40698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40699         RoutingFees_set_base_msat(&this_ptr_conv, val);
40700 }
40701
40702 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
40703         LDKRoutingFees this_ptr_conv;
40704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40705         this_ptr_conv.is_owned = false;
40706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40707         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40708         return ret_conv;
40709 }
40710
40711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40712         LDKRoutingFees this_ptr_conv;
40713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40714         this_ptr_conv.is_owned = false;
40715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40716         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40717 }
40718
40719 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) {
40720         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40721         int64_t ret_ref = 0;
40722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40725         ret_ref = (uintptr_t)ret_var.inner;
40726         if (ret_var.is_owned) {
40727                 ret_ref |= 1;
40728         }
40729         return ret_ref;
40730 }
40731
40732 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40733         LDKRoutingFees a_conv;
40734         a_conv.inner = (void*)(a & (~1));
40735         a_conv.is_owned = false;
40736         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40737         LDKRoutingFees b_conv;
40738         b_conv.inner = (void*)(b & (~1));
40739         b_conv.is_owned = false;
40740         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40741         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
40742         return ret_conv;
40743 }
40744
40745 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40746         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40747 int64_t ret_ref = 0;
40748 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40749 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40750 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40751 ret_ref = (uintptr_t)ret_var.inner;
40752 if (ret_var.is_owned) {
40753         ret_ref |= 1;
40754 }
40755         return ret_ref;
40756 }
40757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40758         LDKRoutingFees arg_conv;
40759         arg_conv.inner = (void*)(arg & (~1));
40760         arg_conv.is_owned = false;
40761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40762         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
40763         return ret_conv;
40764 }
40765
40766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40767         LDKRoutingFees orig_conv;
40768         orig_conv.inner = (void*)(orig & (~1));
40769         orig_conv.is_owned = false;
40770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40771         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40772         int64_t ret_ref = 0;
40773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40776         ret_ref = (uintptr_t)ret_var.inner;
40777         if (ret_var.is_owned) {
40778                 ret_ref |= 1;
40779         }
40780         return ret_ref;
40781 }
40782
40783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
40784         LDKRoutingFees o_conv;
40785         o_conv.inner = (void*)(o & (~1));
40786         o_conv.is_owned = false;
40787         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40788         int64_t ret_conv = RoutingFees_hash(&o_conv);
40789         return ret_conv;
40790 }
40791
40792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
40793         LDKRoutingFees obj_conv;
40794         obj_conv.inner = (void*)(obj & (~1));
40795         obj_conv.is_owned = false;
40796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40797         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40798         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40799         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40800         CVec_u8Z_free(ret_var);
40801         return ret_arr;
40802 }
40803
40804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40805         LDKu8slice ser_ref;
40806         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40807         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40808         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40809         *ret_conv = RoutingFees_read(ser_ref);
40810         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40811         return (int64_t)ret_conv;
40812 }
40813
40814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40815         LDKNodeAnnouncementInfo this_obj_conv;
40816         this_obj_conv.inner = (void*)(this_obj & (~1));
40817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40819         NodeAnnouncementInfo_free(this_obj_conv);
40820 }
40821
40822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40823         LDKNodeAnnouncementInfo this_ptr_conv;
40824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40825         this_ptr_conv.is_owned = false;
40826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40827         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40828         int64_t ret_ref = 0;
40829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40832         ret_ref = (uintptr_t)ret_var.inner;
40833         if (ret_var.is_owned) {
40834                 ret_ref |= 1;
40835         }
40836         return ret_ref;
40837 }
40838
40839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40840         LDKNodeAnnouncementInfo this_ptr_conv;
40841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40842         this_ptr_conv.is_owned = false;
40843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40844         LDKNodeFeatures val_conv;
40845         val_conv.inner = (void*)(val & (~1));
40846         val_conv.is_owned = (val & 1) || (val == 0);
40847         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40848         val_conv = NodeFeatures_clone(&val_conv);
40849         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40850 }
40851
40852 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
40853         LDKNodeAnnouncementInfo this_ptr_conv;
40854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40855         this_ptr_conv.is_owned = false;
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40857         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40858         return ret_conv;
40859 }
40860
40861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40862         LDKNodeAnnouncementInfo this_ptr_conv;
40863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40864         this_ptr_conv.is_owned = false;
40865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40866         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40867 }
40868
40869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
40870         LDKNodeAnnouncementInfo this_ptr_conv;
40871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40872         this_ptr_conv.is_owned = false;
40873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40874         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
40875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
40876         return ret_arr;
40877 }
40878
40879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40880         LDKNodeAnnouncementInfo this_ptr_conv;
40881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40882         this_ptr_conv.is_owned = false;
40883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40884         LDKThreeBytes val_ref;
40885         CHECK((*env)->GetArrayLength(env, val) == 3);
40886         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
40887         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40888 }
40889
40890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
40891         LDKNodeAnnouncementInfo this_ptr_conv;
40892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40893         this_ptr_conv.is_owned = false;
40894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40895         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40896         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
40897         return ret_arr;
40898 }
40899
40900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40901         LDKNodeAnnouncementInfo this_ptr_conv;
40902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40903         this_ptr_conv.is_owned = false;
40904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40905         LDKThirtyTwoBytes val_ref;
40906         CHECK((*env)->GetArrayLength(env, val) == 32);
40907         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40908         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
40909 }
40910
40911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40912         LDKNodeAnnouncementInfo this_ptr_conv;
40913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40914         this_ptr_conv.is_owned = false;
40915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40916         LDKCVec_NetAddressZ val_constr;
40917         val_constr.datalen = (*env)->GetArrayLength(env, val);
40918         if (val_constr.datalen > 0)
40919                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40920         else
40921                 val_constr.data = NULL;
40922         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40923         for (size_t m = 0; m < val_constr.datalen; m++) {
40924                 int64_t val_conv_12 = val_vals[m];
40925                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40926                 CHECK_ACCESS(val_conv_12_ptr);
40927                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40928                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40929                 val_constr.data[m] = val_conv_12_conv;
40930         }
40931         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40932         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40933 }
40934
40935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40936         LDKNodeAnnouncementInfo this_ptr_conv;
40937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40938         this_ptr_conv.is_owned = false;
40939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40940         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40941         int64_t ret_ref = 0;
40942         if ((uintptr_t)ret_var.inner > 4096) {
40943                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40944                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40946                 ret_ref = (uintptr_t)ret_var.inner;
40947                 if (ret_var.is_owned) {
40948                         ret_ref |= 1;
40949                 }
40950         }
40951         return ret_ref;
40952 }
40953
40954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40955         LDKNodeAnnouncementInfo this_ptr_conv;
40956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40957         this_ptr_conv.is_owned = false;
40958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40959         LDKNodeAnnouncement val_conv;
40960         val_conv.inner = (void*)(val & (~1));
40961         val_conv.is_owned = (val & 1) || (val == 0);
40962         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40963         val_conv = NodeAnnouncement_clone(&val_conv);
40964         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40965 }
40966
40967 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) {
40968         LDKNodeFeatures features_arg_conv;
40969         features_arg_conv.inner = (void*)(features_arg & (~1));
40970         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40971         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40972         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40973         LDKThreeBytes rgb_arg_ref;
40974         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
40975         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
40976         LDKThirtyTwoBytes alias_arg_ref;
40977         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
40978         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
40979         LDKCVec_NetAddressZ addresses_arg_constr;
40980         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
40981         if (addresses_arg_constr.datalen > 0)
40982                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40983         else
40984                 addresses_arg_constr.data = NULL;
40985         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
40986         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40987                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
40988                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40989                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40990                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40991                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40992         }
40993         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
40994         LDKNodeAnnouncement announcement_message_arg_conv;
40995         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40996         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40997         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40998         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40999         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
41000         int64_t ret_ref = 0;
41001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41004         ret_ref = (uintptr_t)ret_var.inner;
41005         if (ret_var.is_owned) {
41006                 ret_ref |= 1;
41007         }
41008         return ret_ref;
41009 }
41010
41011 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
41012         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
41013 int64_t ret_ref = 0;
41014 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41015 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41016 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41017 ret_ref = (uintptr_t)ret_var.inner;
41018 if (ret_var.is_owned) {
41019         ret_ref |= 1;
41020 }
41021         return ret_ref;
41022 }
41023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41024         LDKNodeAnnouncementInfo arg_conv;
41025         arg_conv.inner = (void*)(arg & (~1));
41026         arg_conv.is_owned = false;
41027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41028         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
41029         return ret_conv;
41030 }
41031
41032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41033         LDKNodeAnnouncementInfo orig_conv;
41034         orig_conv.inner = (void*)(orig & (~1));
41035         orig_conv.is_owned = false;
41036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41037         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
41038         int64_t ret_ref = 0;
41039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41042         ret_ref = (uintptr_t)ret_var.inner;
41043         if (ret_var.is_owned) {
41044                 ret_ref |= 1;
41045         }
41046         return ret_ref;
41047 }
41048
41049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41050         LDKNodeAnnouncementInfo obj_conv;
41051         obj_conv.inner = (void*)(obj & (~1));
41052         obj_conv.is_owned = false;
41053         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41054         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
41055         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41056         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41057         CVec_u8Z_free(ret_var);
41058         return ret_arr;
41059 }
41060
41061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41062         LDKu8slice ser_ref;
41063         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41064         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41065         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
41066         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
41067         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41068         return (int64_t)ret_conv;
41069 }
41070
41071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41072         LDKNodeInfo this_obj_conv;
41073         this_obj_conv.inner = (void*)(this_obj & (~1));
41074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41076         NodeInfo_free(this_obj_conv);
41077 }
41078
41079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41080         LDKNodeInfo this_ptr_conv;
41081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41082         this_ptr_conv.is_owned = false;
41083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41084         LDKCVec_u64Z val_constr;
41085         val_constr.datalen = (*env)->GetArrayLength(env, val);
41086         if (val_constr.datalen > 0)
41087                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41088         else
41089                 val_constr.data = NULL;
41090         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41091         for (size_t g = 0; g < val_constr.datalen; g++) {
41092                 int64_t val_conv_6 = val_vals[g];
41093                 val_constr.data[g] = val_conv_6;
41094         }
41095         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41096         NodeInfo_set_channels(&this_ptr_conv, val_constr);
41097 }
41098
41099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
41100         LDKNodeInfo this_ptr_conv;
41101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41102         this_ptr_conv.is_owned = false;
41103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41104         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
41105         int64_t ret_ref = 0;
41106         if ((uintptr_t)ret_var.inner > 4096) {
41107                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41108                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41110                 ret_ref = (uintptr_t)ret_var.inner;
41111                 if (ret_var.is_owned) {
41112                         ret_ref |= 1;
41113                 }
41114         }
41115         return ret_ref;
41116 }
41117
41118 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) {
41119         LDKNodeInfo this_ptr_conv;
41120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41121         this_ptr_conv.is_owned = false;
41122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41123         LDKRoutingFees val_conv;
41124         val_conv.inner = (void*)(val & (~1));
41125         val_conv.is_owned = (val & 1) || (val == 0);
41126         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41127         val_conv = RoutingFees_clone(&val_conv);
41128         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
41129 }
41130
41131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
41132         LDKNodeInfo this_ptr_conv;
41133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41134         this_ptr_conv.is_owned = false;
41135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41136         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
41137         int64_t ret_ref = 0;
41138         if ((uintptr_t)ret_var.inner > 4096) {
41139                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41140                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41142                 ret_ref = (uintptr_t)ret_var.inner;
41143                 if (ret_var.is_owned) {
41144                         ret_ref |= 1;
41145                 }
41146         }
41147         return ret_ref;
41148 }
41149
41150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41151         LDKNodeInfo this_ptr_conv;
41152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41153         this_ptr_conv.is_owned = false;
41154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41155         LDKNodeAnnouncementInfo val_conv;
41156         val_conv.inner = (void*)(val & (~1));
41157         val_conv.is_owned = (val & 1) || (val == 0);
41158         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41159         val_conv = NodeAnnouncementInfo_clone(&val_conv);
41160         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
41161 }
41162
41163 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) {
41164         LDKCVec_u64Z channels_arg_constr;
41165         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
41166         if (channels_arg_constr.datalen > 0)
41167                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41168         else
41169                 channels_arg_constr.data = NULL;
41170         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
41171         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
41172                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
41173                 channels_arg_constr.data[g] = channels_arg_conv_6;
41174         }
41175         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
41176         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
41177         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
41178         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
41180         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
41181         LDKNodeAnnouncementInfo announcement_info_arg_conv;
41182         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
41183         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
41184         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
41185         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
41186         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
41187         int64_t ret_ref = 0;
41188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41191         ret_ref = (uintptr_t)ret_var.inner;
41192         if (ret_var.is_owned) {
41193                 ret_ref |= 1;
41194         }
41195         return ret_ref;
41196 }
41197
41198 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
41199         LDKNodeInfo ret_var = NodeInfo_clone(arg);
41200 int64_t ret_ref = 0;
41201 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41202 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41203 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41204 ret_ref = (uintptr_t)ret_var.inner;
41205 if (ret_var.is_owned) {
41206         ret_ref |= 1;
41207 }
41208         return ret_ref;
41209 }
41210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41211         LDKNodeInfo arg_conv;
41212         arg_conv.inner = (void*)(arg & (~1));
41213         arg_conv.is_owned = false;
41214         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41215         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
41216         return ret_conv;
41217 }
41218
41219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41220         LDKNodeInfo orig_conv;
41221         orig_conv.inner = (void*)(orig & (~1));
41222         orig_conv.is_owned = false;
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41224         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
41225         int64_t ret_ref = 0;
41226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41229         ret_ref = (uintptr_t)ret_var.inner;
41230         if (ret_var.is_owned) {
41231                 ret_ref |= 1;
41232         }
41233         return ret_ref;
41234 }
41235
41236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41237         LDKNodeInfo obj_conv;
41238         obj_conv.inner = (void*)(obj & (~1));
41239         obj_conv.is_owned = false;
41240         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41241         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
41242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41244         CVec_u8Z_free(ret_var);
41245         return ret_arr;
41246 }
41247
41248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41249         LDKu8slice ser_ref;
41250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41252         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
41253         *ret_conv = NodeInfo_read(ser_ref);
41254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41255         return (int64_t)ret_conv;
41256 }
41257
41258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
41259         LDKNetworkGraph obj_conv;
41260         obj_conv.inner = (void*)(obj & (~1));
41261         obj_conv.is_owned = false;
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41263         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
41264         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41265         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41266         CVec_u8Z_free(ret_var);
41267         return ret_arr;
41268 }
41269
41270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41271         LDKu8slice ser_ref;
41272         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41273         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41274         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
41275         *ret_conv = NetworkGraph_read(ser_ref);
41276         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41277         return (int64_t)ret_conv;
41278 }
41279
41280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
41281         LDKThirtyTwoBytes genesis_hash_ref;
41282         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
41283         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
41284         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
41285         int64_t ret_ref = 0;
41286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41289         ret_ref = (uintptr_t)ret_var.inner;
41290         if (ret_var.is_owned) {
41291                 ret_ref |= 1;
41292         }
41293         return ret_ref;
41294 }
41295
41296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
41297         LDKNetworkGraph this_arg_conv;
41298         this_arg_conv.inner = (void*)(this_arg & (~1));
41299         this_arg_conv.is_owned = false;
41300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41301         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
41302         int64_t ret_ref = 0;
41303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41306         ret_ref = (uintptr_t)ret_var.inner;
41307         if (ret_var.is_owned) {
41308                 ret_ref |= 1;
41309         }
41310         return ret_ref;
41311 }
41312
41313 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) {
41314         LDKNetworkGraph this_arg_conv;
41315         this_arg_conv.inner = (void*)(this_arg & (~1));
41316         this_arg_conv.is_owned = false;
41317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41318         LDKNodeAnnouncement msg_conv;
41319         msg_conv.inner = (void*)(msg & (~1));
41320         msg_conv.is_owned = false;
41321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41322         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41323         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
41324         return (int64_t)ret_conv;
41325 }
41326
41327 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) {
41328         LDKNetworkGraph this_arg_conv;
41329         this_arg_conv.inner = (void*)(this_arg & (~1));
41330         this_arg_conv.is_owned = false;
41331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41332         LDKUnsignedNodeAnnouncement msg_conv;
41333         msg_conv.inner = (void*)(msg & (~1));
41334         msg_conv.is_owned = false;
41335         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41336         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41337         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
41338         return (int64_t)ret_conv;
41339 }
41340
41341 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) {
41342         LDKNetworkGraph this_arg_conv;
41343         this_arg_conv.inner = (void*)(this_arg & (~1));
41344         this_arg_conv.is_owned = false;
41345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41346         LDKChannelAnnouncement msg_conv;
41347         msg_conv.inner = (void*)(msg & (~1));
41348         msg_conv.is_owned = false;
41349         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41350         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41351         CHECK_ACCESS(chain_access_ptr);
41352         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41353         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41354         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41355                 // Manually implement clone for Java trait instances
41356                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41357                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41358                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41359                 }
41360         }
41361         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41362         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41363         return (int64_t)ret_conv;
41364 }
41365
41366 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) {
41367         LDKNetworkGraph this_arg_conv;
41368         this_arg_conv.inner = (void*)(this_arg & (~1));
41369         this_arg_conv.is_owned = false;
41370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41371         LDKUnsignedChannelAnnouncement msg_conv;
41372         msg_conv.inner = (void*)(msg & (~1));
41373         msg_conv.is_owned = false;
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41375         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41376         CHECK_ACCESS(chain_access_ptr);
41377         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41378         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41379         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41380                 // Manually implement clone for Java trait instances
41381                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41382                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41383                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41384                 }
41385         }
41386         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41387         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41388         return (int64_t)ret_conv;
41389 }
41390
41391 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) {
41392         LDKNetworkGraph this_arg_conv;
41393         this_arg_conv.inner = (void*)(this_arg & (~1));
41394         this_arg_conv.is_owned = false;
41395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41396         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
41397 }
41398
41399 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) {
41400         LDKNetworkGraph this_arg_conv;
41401         this_arg_conv.inner = (void*)(this_arg & (~1));
41402         this_arg_conv.is_owned = false;
41403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41404         LDKPublicKey _node_id_ref;
41405         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
41406         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
41407         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
41408 }
41409
41410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
41411         LDKNetworkGraph this_arg_conv;
41412         this_arg_conv.inner = (void*)(this_arg & (~1));
41413         this_arg_conv.is_owned = false;
41414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41415         NetworkGraph_remove_stale_channels(&this_arg_conv);
41416 }
41417
41418 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) {
41419         LDKNetworkGraph this_arg_conv;
41420         this_arg_conv.inner = (void*)(this_arg & (~1));
41421         this_arg_conv.is_owned = false;
41422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41423         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
41424 }
41425
41426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
41427         LDKNetworkGraph this_arg_conv;
41428         this_arg_conv.inner = (void*)(this_arg & (~1));
41429         this_arg_conv.is_owned = false;
41430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41431         LDKChannelUpdate msg_conv;
41432         msg_conv.inner = (void*)(msg & (~1));
41433         msg_conv.is_owned = false;
41434         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41435         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41436         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
41437         return (int64_t)ret_conv;
41438 }
41439
41440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
41441         LDKNetworkGraph this_arg_conv;
41442         this_arg_conv.inner = (void*)(this_arg & (~1));
41443         this_arg_conv.is_owned = false;
41444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41445         LDKUnsignedChannelUpdate msg_conv;
41446         msg_conv.inner = (void*)(msg & (~1));
41447         msg_conv.is_owned = false;
41448         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41449         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41450         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41451         return (int64_t)ret_conv;
41452 }
41453
41454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
41455         LDKReadOnlyNetworkGraph this_arg_conv;
41456         this_arg_conv.inner = (void*)(this_arg & (~1));
41457         this_arg_conv.is_owned = false;
41458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41459         LDKPublicKey pubkey_ref;
41460         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
41461         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
41462         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41463         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41464         int64_t ret_ref = (uintptr_t)ret_copy;
41465         return ret_ref;
41466 }
41467
41468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41469         LDKRouteHop this_obj_conv;
41470         this_obj_conv.inner = (void*)(this_obj & (~1));
41471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41473         RouteHop_free(this_obj_conv);
41474 }
41475
41476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41477         LDKRouteHop this_ptr_conv;
41478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41479         this_ptr_conv.is_owned = false;
41480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41481         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41482         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
41483         return ret_arr;
41484 }
41485
41486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41487         LDKRouteHop this_ptr_conv;
41488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41489         this_ptr_conv.is_owned = false;
41490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41491         LDKPublicKey val_ref;
41492         CHECK((*env)->GetArrayLength(env, val) == 33);
41493         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41494         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41495 }
41496
41497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41498         LDKRouteHop this_ptr_conv;
41499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41500         this_ptr_conv.is_owned = false;
41501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41502         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41503         int64_t ret_ref = 0;
41504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41507         ret_ref = (uintptr_t)ret_var.inner;
41508         if (ret_var.is_owned) {
41509                 ret_ref |= 1;
41510         }
41511         return ret_ref;
41512 }
41513
41514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41515         LDKRouteHop this_ptr_conv;
41516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41517         this_ptr_conv.is_owned = false;
41518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41519         LDKNodeFeatures val_conv;
41520         val_conv.inner = (void*)(val & (~1));
41521         val_conv.is_owned = (val & 1) || (val == 0);
41522         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41523         val_conv = NodeFeatures_clone(&val_conv);
41524         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41525 }
41526
41527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
41528         LDKRouteHop this_ptr_conv;
41529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41530         this_ptr_conv.is_owned = false;
41531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41532         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
41533         return ret_conv;
41534 }
41535
41536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41537         LDKRouteHop this_ptr_conv;
41538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41539         this_ptr_conv.is_owned = false;
41540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41541         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41542 }
41543
41544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41545         LDKRouteHop this_ptr_conv;
41546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41547         this_ptr_conv.is_owned = false;
41548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41549         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41550         int64_t ret_ref = 0;
41551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41554         ret_ref = (uintptr_t)ret_var.inner;
41555         if (ret_var.is_owned) {
41556                 ret_ref |= 1;
41557         }
41558         return ret_ref;
41559 }
41560
41561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41562         LDKRouteHop this_ptr_conv;
41563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41564         this_ptr_conv.is_owned = false;
41565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41566         LDKChannelFeatures val_conv;
41567         val_conv.inner = (void*)(val & (~1));
41568         val_conv.is_owned = (val & 1) || (val == 0);
41569         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41570         val_conv = ChannelFeatures_clone(&val_conv);
41571         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41572 }
41573
41574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41575         LDKRouteHop this_ptr_conv;
41576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41577         this_ptr_conv.is_owned = false;
41578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41579         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
41580         return ret_conv;
41581 }
41582
41583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41584         LDKRouteHop this_ptr_conv;
41585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41586         this_ptr_conv.is_owned = false;
41587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41588         RouteHop_set_fee_msat(&this_ptr_conv, val);
41589 }
41590
41591 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41592         LDKRouteHop this_ptr_conv;
41593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41594         this_ptr_conv.is_owned = false;
41595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41596         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41597         return ret_conv;
41598 }
41599
41600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41601         LDKRouteHop this_ptr_conv;
41602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41603         this_ptr_conv.is_owned = false;
41604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41605         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41606 }
41607
41608 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) {
41609         LDKPublicKey pubkey_arg_ref;
41610         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
41611         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
41612         LDKNodeFeatures node_features_arg_conv;
41613         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41614         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41615         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41616         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41617         LDKChannelFeatures channel_features_arg_conv;
41618         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41619         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41620         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41621         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41622         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);
41623         int64_t ret_ref = 0;
41624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41627         ret_ref = (uintptr_t)ret_var.inner;
41628         if (ret_var.is_owned) {
41629                 ret_ref |= 1;
41630         }
41631         return ret_ref;
41632 }
41633
41634 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41635         LDKRouteHop ret_var = RouteHop_clone(arg);
41636 int64_t ret_ref = 0;
41637 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41638 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41639 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41640 ret_ref = (uintptr_t)ret_var.inner;
41641 if (ret_var.is_owned) {
41642         ret_ref |= 1;
41643 }
41644         return ret_ref;
41645 }
41646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41647         LDKRouteHop arg_conv;
41648         arg_conv.inner = (void*)(arg & (~1));
41649         arg_conv.is_owned = false;
41650         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41651         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
41652         return ret_conv;
41653 }
41654
41655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41656         LDKRouteHop orig_conv;
41657         orig_conv.inner = (void*)(orig & (~1));
41658         orig_conv.is_owned = false;
41659         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41660         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41661         int64_t ret_ref = 0;
41662         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41663         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41665         ret_ref = (uintptr_t)ret_var.inner;
41666         if (ret_var.is_owned) {
41667                 ret_ref |= 1;
41668         }
41669         return ret_ref;
41670 }
41671
41672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
41673         LDKRouteHop o_conv;
41674         o_conv.inner = (void*)(o & (~1));
41675         o_conv.is_owned = false;
41676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41677         int64_t ret_conv = RouteHop_hash(&o_conv);
41678         return ret_conv;
41679 }
41680
41681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41682         LDKRouteHop a_conv;
41683         a_conv.inner = (void*)(a & (~1));
41684         a_conv.is_owned = false;
41685         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41686         LDKRouteHop b_conv;
41687         b_conv.inner = (void*)(b & (~1));
41688         b_conv.is_owned = false;
41689         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41690         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
41691         return ret_conv;
41692 }
41693
41694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
41695         LDKRouteHop obj_conv;
41696         obj_conv.inner = (void*)(obj & (~1));
41697         obj_conv.is_owned = false;
41698         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41699         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41700         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41701         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41702         CVec_u8Z_free(ret_var);
41703         return ret_arr;
41704 }
41705
41706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41707         LDKu8slice ser_ref;
41708         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41709         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41710         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41711         *ret_conv = RouteHop_read(ser_ref);
41712         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41713         return (int64_t)ret_conv;
41714 }
41715
41716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41717         LDKRoute this_obj_conv;
41718         this_obj_conv.inner = (void*)(this_obj & (~1));
41719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41721         Route_free(this_obj_conv);
41722 }
41723
41724 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
41725         LDKRoute this_ptr_conv;
41726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41727         this_ptr_conv.is_owned = false;
41728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41729         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41730         jobjectArray ret_arr = NULL;
41731         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
41732         ;
41733         for (size_t m = 0; m < ret_var.datalen; m++) {
41734                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41735                 int64_tArray ret_conv_12_arr = NULL;
41736                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
41737                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
41738                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41739                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41740                         int64_t ret_conv_12_conv_10_ref = 0;
41741                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41742                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41743                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41744                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41745                         if (ret_conv_12_conv_10_var.is_owned) {
41746                                 ret_conv_12_conv_10_ref |= 1;
41747                         }
41748                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41749                 }
41750                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
41751                 FREE(ret_conv_12_var.data);
41752                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
41753         }
41754         
41755         FREE(ret_var.data);
41756         return ret_arr;
41757 }
41758
41759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41760         LDKRoute this_ptr_conv;
41761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41762         this_ptr_conv.is_owned = false;
41763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41764         LDKCVec_CVec_RouteHopZZ val_constr;
41765         val_constr.datalen = (*env)->GetArrayLength(env, val);
41766         if (val_constr.datalen > 0)
41767                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41768         else
41769                 val_constr.data = NULL;
41770         for (size_t m = 0; m < val_constr.datalen; m++) {
41771                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
41772                 LDKCVec_RouteHopZ val_conv_12_constr;
41773                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
41774                 if (val_conv_12_constr.datalen > 0)
41775                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41776                 else
41777                         val_conv_12_constr.data = NULL;
41778                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
41779                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41780                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
41781                         LDKRouteHop val_conv_12_conv_10_conv;
41782                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41783                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41784                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41785                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41786                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41787                 }
41788                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
41789                 val_constr.data[m] = val_conv_12_constr;
41790         }
41791         Route_set_paths(&this_ptr_conv, val_constr);
41792 }
41793
41794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41795         LDKRoute this_ptr_conv;
41796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41797         this_ptr_conv.is_owned = false;
41798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41799         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41800         int64_t ret_ref = 0;
41801         if ((uintptr_t)ret_var.inner > 4096) {
41802                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41803                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41805                 ret_ref = (uintptr_t)ret_var.inner;
41806                 if (ret_var.is_owned) {
41807                         ret_ref |= 1;
41808                 }
41809         }
41810         return ret_ref;
41811 }
41812
41813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41814         LDKRoute this_ptr_conv;
41815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41816         this_ptr_conv.is_owned = false;
41817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41818         LDKPaymentParameters val_conv;
41819         val_conv.inner = (void*)(val & (~1));
41820         val_conv.is_owned = (val & 1) || (val == 0);
41821         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41822         val_conv = PaymentParameters_clone(&val_conv);
41823         Route_set_payment_params(&this_ptr_conv, val_conv);
41824 }
41825
41826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
41827         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41828         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
41829         if (paths_arg_constr.datalen > 0)
41830                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41831         else
41832                 paths_arg_constr.data = NULL;
41833         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41834                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
41835                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41836                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
41837                 if (paths_arg_conv_12_constr.datalen > 0)
41838                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41839                 else
41840                         paths_arg_conv_12_constr.data = NULL;
41841                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
41842                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41843                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41844                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41845                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41846                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41847                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41848                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41849                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41850                 }
41851                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
41852                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41853         }
41854         LDKPaymentParameters payment_params_arg_conv;
41855         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41856         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41857         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41858         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41859         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41860         int64_t ret_ref = 0;
41861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41864         ret_ref = (uintptr_t)ret_var.inner;
41865         if (ret_var.is_owned) {
41866                 ret_ref |= 1;
41867         }
41868         return ret_ref;
41869 }
41870
41871 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41872         LDKRoute ret_var = Route_clone(arg);
41873 int64_t ret_ref = 0;
41874 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41875 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41877 ret_ref = (uintptr_t)ret_var.inner;
41878 if (ret_var.is_owned) {
41879         ret_ref |= 1;
41880 }
41881         return ret_ref;
41882 }
41883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41884         LDKRoute arg_conv;
41885         arg_conv.inner = (void*)(arg & (~1));
41886         arg_conv.is_owned = false;
41887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41888         int64_t ret_conv = Route_clone_ptr(&arg_conv);
41889         return ret_conv;
41890 }
41891
41892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41893         LDKRoute orig_conv;
41894         orig_conv.inner = (void*)(orig & (~1));
41895         orig_conv.is_owned = false;
41896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41897         LDKRoute ret_var = Route_clone(&orig_conv);
41898         int64_t ret_ref = 0;
41899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41902         ret_ref = (uintptr_t)ret_var.inner;
41903         if (ret_var.is_owned) {
41904                 ret_ref |= 1;
41905         }
41906         return ret_ref;
41907 }
41908
41909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
41910         LDKRoute o_conv;
41911         o_conv.inner = (void*)(o & (~1));
41912         o_conv.is_owned = false;
41913         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41914         int64_t ret_conv = Route_hash(&o_conv);
41915         return ret_conv;
41916 }
41917
41918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41919         LDKRoute a_conv;
41920         a_conv.inner = (void*)(a & (~1));
41921         a_conv.is_owned = false;
41922         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41923         LDKRoute b_conv;
41924         b_conv.inner = (void*)(b & (~1));
41925         b_conv.is_owned = false;
41926         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41927         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
41928         return ret_conv;
41929 }
41930
41931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
41932         LDKRoute this_arg_conv;
41933         this_arg_conv.inner = (void*)(this_arg & (~1));
41934         this_arg_conv.is_owned = false;
41935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41936         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
41937         return ret_conv;
41938 }
41939
41940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
41941         LDKRoute this_arg_conv;
41942         this_arg_conv.inner = (void*)(this_arg & (~1));
41943         this_arg_conv.is_owned = false;
41944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41945         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
41946         return ret_conv;
41947 }
41948
41949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
41950         LDKRoute obj_conv;
41951         obj_conv.inner = (void*)(obj & (~1));
41952         obj_conv.is_owned = false;
41953         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41954         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41955         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41956         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41957         CVec_u8Z_free(ret_var);
41958         return ret_arr;
41959 }
41960
41961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41962         LDKu8slice ser_ref;
41963         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41964         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41965         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41966         *ret_conv = Route_read(ser_ref);
41967         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41968         return (int64_t)ret_conv;
41969 }
41970
41971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41972         LDKRouteParameters this_obj_conv;
41973         this_obj_conv.inner = (void*)(this_obj & (~1));
41974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41976         RouteParameters_free(this_obj_conv);
41977 }
41978
41979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41980         LDKRouteParameters this_ptr_conv;
41981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41982         this_ptr_conv.is_owned = false;
41983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41984         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41985         int64_t ret_ref = 0;
41986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41989         ret_ref = (uintptr_t)ret_var.inner;
41990         if (ret_var.is_owned) {
41991                 ret_ref |= 1;
41992         }
41993         return ret_ref;
41994 }
41995
41996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41997         LDKRouteParameters this_ptr_conv;
41998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41999         this_ptr_conv.is_owned = false;
42000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42001         LDKPaymentParameters val_conv;
42002         val_conv.inner = (void*)(val & (~1));
42003         val_conv.is_owned = (val & 1) || (val == 0);
42004         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42005         val_conv = PaymentParameters_clone(&val_conv);
42006         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
42007 }
42008
42009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42010         LDKRouteParameters this_ptr_conv;
42011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42012         this_ptr_conv.is_owned = false;
42013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42014         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
42015         return ret_conv;
42016 }
42017
42018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42019         LDKRouteParameters this_ptr_conv;
42020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42021         this_ptr_conv.is_owned = false;
42022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42023         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
42024 }
42025
42026 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42027         LDKRouteParameters this_ptr_conv;
42028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42029         this_ptr_conv.is_owned = false;
42030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42031         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
42032         return ret_conv;
42033 }
42034
42035 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) {
42036         LDKRouteParameters this_ptr_conv;
42037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42038         this_ptr_conv.is_owned = false;
42039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42040         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
42041 }
42042
42043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payment_params_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
42044         LDKPaymentParameters payment_params_arg_conv;
42045         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
42046         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
42047         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
42048         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
42049         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
42050         int64_t ret_ref = 0;
42051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42054         ret_ref = (uintptr_t)ret_var.inner;
42055         if (ret_var.is_owned) {
42056                 ret_ref |= 1;
42057         }
42058         return ret_ref;
42059 }
42060
42061 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
42062         LDKRouteParameters ret_var = RouteParameters_clone(arg);
42063 int64_t ret_ref = 0;
42064 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42065 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42066 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42067 ret_ref = (uintptr_t)ret_var.inner;
42068 if (ret_var.is_owned) {
42069         ret_ref |= 1;
42070 }
42071         return ret_ref;
42072 }
42073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42074         LDKRouteParameters arg_conv;
42075         arg_conv.inner = (void*)(arg & (~1));
42076         arg_conv.is_owned = false;
42077         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42078         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
42079         return ret_conv;
42080 }
42081
42082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42083         LDKRouteParameters orig_conv;
42084         orig_conv.inner = (void*)(orig & (~1));
42085         orig_conv.is_owned = false;
42086         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42087         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
42088         int64_t ret_ref = 0;
42089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42092         ret_ref = (uintptr_t)ret_var.inner;
42093         if (ret_var.is_owned) {
42094                 ret_ref |= 1;
42095         }
42096         return ret_ref;
42097 }
42098
42099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42100         LDKRouteParameters obj_conv;
42101         obj_conv.inner = (void*)(obj & (~1));
42102         obj_conv.is_owned = false;
42103         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42104         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
42105         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42106         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42107         CVec_u8Z_free(ret_var);
42108         return ret_arr;
42109 }
42110
42111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42112         LDKu8slice ser_ref;
42113         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42114         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42115         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
42116         *ret_conv = RouteParameters_read(ser_ref);
42117         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42118         return (int64_t)ret_conv;
42119 }
42120
42121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42122         LDKPaymentParameters this_obj_conv;
42123         this_obj_conv.inner = (void*)(this_obj & (~1));
42124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42126         PaymentParameters_free(this_obj_conv);
42127 }
42128
42129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42130         LDKPaymentParameters this_ptr_conv;
42131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42132         this_ptr_conv.is_owned = false;
42133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42134         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42135         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
42136         return ret_arr;
42137 }
42138
42139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42140         LDKPaymentParameters this_ptr_conv;
42141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42142         this_ptr_conv.is_owned = false;
42143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42144         LDKPublicKey val_ref;
42145         CHECK((*env)->GetArrayLength(env, val) == 33);
42146         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42147         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
42148 }
42149
42150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42151         LDKPaymentParameters this_ptr_conv;
42152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42153         this_ptr_conv.is_owned = false;
42154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42155         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
42156         int64_t ret_ref = 0;
42157         if ((uintptr_t)ret_var.inner > 4096) {
42158                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42159                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42161                 ret_ref = (uintptr_t)ret_var.inner;
42162                 if (ret_var.is_owned) {
42163                         ret_ref |= 1;
42164                 }
42165         }
42166         return ret_ref;
42167 }
42168
42169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42170         LDKPaymentParameters this_ptr_conv;
42171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42172         this_ptr_conv.is_owned = false;
42173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42174         LDKInvoiceFeatures val_conv;
42175         val_conv.inner = (void*)(val & (~1));
42176         val_conv.is_owned = (val & 1) || (val == 0);
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42178         val_conv = InvoiceFeatures_clone(&val_conv);
42179         PaymentParameters_set_features(&this_ptr_conv, val_conv);
42180 }
42181
42182 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
42183         LDKPaymentParameters this_ptr_conv;
42184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42185         this_ptr_conv.is_owned = false;
42186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42187         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
42188         int64_tArray ret_arr = NULL;
42189         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42190         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42191         for (size_t l = 0; l < ret_var.datalen; l++) {
42192                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
42193                 int64_t ret_conv_11_ref = 0;
42194                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42195                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42196                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
42197                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
42198                 if (ret_conv_11_var.is_owned) {
42199                         ret_conv_11_ref |= 1;
42200                 }
42201                 ret_arr_ptr[l] = ret_conv_11_ref;
42202         }
42203         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42204         FREE(ret_var.data);
42205         return ret_arr;
42206 }
42207
42208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42209         LDKPaymentParameters this_ptr_conv;
42210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42211         this_ptr_conv.is_owned = false;
42212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42213         LDKCVec_RouteHintZ val_constr;
42214         val_constr.datalen = (*env)->GetArrayLength(env, val);
42215         if (val_constr.datalen > 0)
42216                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42217         else
42218                 val_constr.data = NULL;
42219         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42220         for (size_t l = 0; l < val_constr.datalen; l++) {
42221                 int64_t val_conv_11 = val_vals[l];
42222                 LDKRouteHint val_conv_11_conv;
42223                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
42224                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
42225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
42226                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
42227                 val_constr.data[l] = val_conv_11_conv;
42228         }
42229         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42230         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
42231 }
42232
42233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
42234         LDKPaymentParameters this_ptr_conv;
42235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42236         this_ptr_conv.is_owned = false;
42237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42238         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42239         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
42240         int64_t ret_ref = (uintptr_t)ret_copy;
42241         return ret_ref;
42242 }
42243
42244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42245         LDKPaymentParameters this_ptr_conv;
42246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42247         this_ptr_conv.is_owned = false;
42248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42249         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42250         CHECK_ACCESS(val_ptr);
42251         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42252         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42253         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
42254 }
42255
42256 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42257         LDKPaymentParameters this_ptr_conv;
42258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42259         this_ptr_conv.is_owned = false;
42260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42261         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
42262         return ret_conv;
42263 }
42264
42265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42266         LDKPaymentParameters this_ptr_conv;
42267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42268         this_ptr_conv.is_owned = false;
42269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42270         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
42271 }
42272
42273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg) {
42274         LDKPublicKey payee_pubkey_arg_ref;
42275         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
42276         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
42277         LDKInvoiceFeatures features_arg_conv;
42278         features_arg_conv.inner = (void*)(features_arg & (~1));
42279         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
42280         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42281         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
42282         LDKCVec_RouteHintZ route_hints_arg_constr;
42283         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
42284         if (route_hints_arg_constr.datalen > 0)
42285                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42286         else
42287                 route_hints_arg_constr.data = NULL;
42288         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
42289         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
42290                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
42291                 LDKRouteHint route_hints_arg_conv_11_conv;
42292                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
42293                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
42294                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
42295                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
42296                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
42297         }
42298         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
42299         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
42300         CHECK_ACCESS(expiry_time_arg_ptr);
42301         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
42302         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
42303         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg);
42304         int64_t ret_ref = 0;
42305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42308         ret_ref = (uintptr_t)ret_var.inner;
42309         if (ret_var.is_owned) {
42310                 ret_ref |= 1;
42311         }
42312         return ret_ref;
42313 }
42314
42315 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
42316         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
42317 int64_t ret_ref = 0;
42318 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42319 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42320 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42321 ret_ref = (uintptr_t)ret_var.inner;
42322 if (ret_var.is_owned) {
42323         ret_ref |= 1;
42324 }
42325         return ret_ref;
42326 }
42327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42328         LDKPaymentParameters arg_conv;
42329         arg_conv.inner = (void*)(arg & (~1));
42330         arg_conv.is_owned = false;
42331         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42332         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
42333         return ret_conv;
42334 }
42335
42336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42337         LDKPaymentParameters orig_conv;
42338         orig_conv.inner = (void*)(orig & (~1));
42339         orig_conv.is_owned = false;
42340         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42341         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42342         int64_t ret_ref = 0;
42343         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42344         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42346         ret_ref = (uintptr_t)ret_var.inner;
42347         if (ret_var.is_owned) {
42348                 ret_ref |= 1;
42349         }
42350         return ret_ref;
42351 }
42352
42353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
42354         LDKPaymentParameters o_conv;
42355         o_conv.inner = (void*)(o & (~1));
42356         o_conv.is_owned = false;
42357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42358         int64_t ret_conv = PaymentParameters_hash(&o_conv);
42359         return ret_conv;
42360 }
42361
42362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42363         LDKPaymentParameters a_conv;
42364         a_conv.inner = (void*)(a & (~1));
42365         a_conv.is_owned = false;
42366         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42367         LDKPaymentParameters b_conv;
42368         b_conv.inner = (void*)(b & (~1));
42369         b_conv.is_owned = false;
42370         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42371         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
42372         return ret_conv;
42373 }
42374
42375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42376         LDKPaymentParameters obj_conv;
42377         obj_conv.inner = (void*)(obj & (~1));
42378         obj_conv.is_owned = false;
42379         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42380         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42381         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42382         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42383         CVec_u8Z_free(ret_var);
42384         return ret_arr;
42385 }
42386
42387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42388         LDKu8slice ser_ref;
42389         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42390         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42391         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42392         *ret_conv = PaymentParameters_read(ser_ref);
42393         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42394         return (int64_t)ret_conv;
42395 }
42396
42397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
42398         LDKPublicKey payee_pubkey_ref;
42399         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
42400         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
42401         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42402         int64_t ret_ref = 0;
42403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42406         ret_ref = (uintptr_t)ret_var.inner;
42407         if (ret_var.is_owned) {
42408                 ret_ref |= 1;
42409         }
42410         return ret_ref;
42411 }
42412
42413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
42414         LDKPublicKey payee_pubkey_ref;
42415         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
42416         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
42417         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42418         int64_t ret_ref = 0;
42419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42422         ret_ref = (uintptr_t)ret_var.inner;
42423         if (ret_var.is_owned) {
42424                 ret_ref |= 1;
42425         }
42426         return ret_ref;
42427 }
42428
42429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42430         LDKRouteHint this_obj_conv;
42431         this_obj_conv.inner = (void*)(this_obj & (~1));
42432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42434         RouteHint_free(this_obj_conv);
42435 }
42436
42437 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
42438         LDKRouteHint this_ptr_conv;
42439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42440         this_ptr_conv.is_owned = false;
42441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42442         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42443         int64_tArray ret_arr = NULL;
42444         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42445         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42446         for (size_t o = 0; o < ret_var.datalen; o++) {
42447                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42448                 int64_t ret_conv_14_ref = 0;
42449                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42450                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42451                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42452                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42453                 if (ret_conv_14_var.is_owned) {
42454                         ret_conv_14_ref |= 1;
42455                 }
42456                 ret_arr_ptr[o] = ret_conv_14_ref;
42457         }
42458         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42459         FREE(ret_var.data);
42460         return ret_arr;
42461 }
42462
42463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42464         LDKRouteHint this_ptr_conv;
42465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42466         this_ptr_conv.is_owned = false;
42467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42468         LDKCVec_RouteHintHopZ val_constr;
42469         val_constr.datalen = (*env)->GetArrayLength(env, val);
42470         if (val_constr.datalen > 0)
42471                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42472         else
42473                 val_constr.data = NULL;
42474         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42475         for (size_t o = 0; o < val_constr.datalen; o++) {
42476                 int64_t val_conv_14 = val_vals[o];
42477                 LDKRouteHintHop val_conv_14_conv;
42478                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
42479                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
42480                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42481                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42482                 val_constr.data[o] = val_conv_14_conv;
42483         }
42484         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42485         RouteHint_set_a(&this_ptr_conv, val_constr);
42486 }
42487
42488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
42489         LDKCVec_RouteHintHopZ a_arg_constr;
42490         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
42491         if (a_arg_constr.datalen > 0)
42492                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42493         else
42494                 a_arg_constr.data = NULL;
42495         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
42496         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42497                 int64_t a_arg_conv_14 = a_arg_vals[o];
42498                 LDKRouteHintHop a_arg_conv_14_conv;
42499                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
42500                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
42501                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42502                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42503                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42504         }
42505         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
42506         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42507         int64_t ret_ref = 0;
42508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42511         ret_ref = (uintptr_t)ret_var.inner;
42512         if (ret_var.is_owned) {
42513                 ret_ref |= 1;
42514         }
42515         return ret_ref;
42516 }
42517
42518 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42519         LDKRouteHint ret_var = RouteHint_clone(arg);
42520 int64_t ret_ref = 0;
42521 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42522 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42523 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42524 ret_ref = (uintptr_t)ret_var.inner;
42525 if (ret_var.is_owned) {
42526         ret_ref |= 1;
42527 }
42528         return ret_ref;
42529 }
42530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42531         LDKRouteHint arg_conv;
42532         arg_conv.inner = (void*)(arg & (~1));
42533         arg_conv.is_owned = false;
42534         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42535         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
42536         return ret_conv;
42537 }
42538
42539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42540         LDKRouteHint orig_conv;
42541         orig_conv.inner = (void*)(orig & (~1));
42542         orig_conv.is_owned = false;
42543         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42544         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42545         int64_t ret_ref = 0;
42546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42549         ret_ref = (uintptr_t)ret_var.inner;
42550         if (ret_var.is_owned) {
42551                 ret_ref |= 1;
42552         }
42553         return ret_ref;
42554 }
42555
42556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
42557         LDKRouteHint o_conv;
42558         o_conv.inner = (void*)(o & (~1));
42559         o_conv.is_owned = false;
42560         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42561         int64_t ret_conv = RouteHint_hash(&o_conv);
42562         return ret_conv;
42563 }
42564
42565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42566         LDKRouteHint a_conv;
42567         a_conv.inner = (void*)(a & (~1));
42568         a_conv.is_owned = false;
42569         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42570         LDKRouteHint b_conv;
42571         b_conv.inner = (void*)(b & (~1));
42572         b_conv.is_owned = false;
42573         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42574         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
42575         return ret_conv;
42576 }
42577
42578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
42579         LDKRouteHint obj_conv;
42580         obj_conv.inner = (void*)(obj & (~1));
42581         obj_conv.is_owned = false;
42582         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42583         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42584         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42585         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42586         CVec_u8Z_free(ret_var);
42587         return ret_arr;
42588 }
42589
42590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42591         LDKu8slice ser_ref;
42592         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42593         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42594         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42595         *ret_conv = RouteHint_read(ser_ref);
42596         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42597         return (int64_t)ret_conv;
42598 }
42599
42600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42601         LDKRouteHintHop this_obj_conv;
42602         this_obj_conv.inner = (void*)(this_obj & (~1));
42603         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42605         RouteHintHop_free(this_obj_conv);
42606 }
42607
42608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42609         LDKRouteHintHop this_ptr_conv;
42610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42611         this_ptr_conv.is_owned = false;
42612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42613         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
42615         return ret_arr;
42616 }
42617
42618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42619         LDKRouteHintHop this_ptr_conv;
42620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42621         this_ptr_conv.is_owned = false;
42622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42623         LDKPublicKey val_ref;
42624         CHECK((*env)->GetArrayLength(env, val) == 33);
42625         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42626         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42627 }
42628
42629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42630         LDKRouteHintHop this_ptr_conv;
42631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42632         this_ptr_conv.is_owned = false;
42633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42634         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42635         return ret_conv;
42636 }
42637
42638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42639         LDKRouteHintHop this_ptr_conv;
42640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42641         this_ptr_conv.is_owned = false;
42642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42643         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42644 }
42645
42646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42647         LDKRouteHintHop this_ptr_conv;
42648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42649         this_ptr_conv.is_owned = false;
42650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42651         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42652         int64_t ret_ref = 0;
42653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42656         ret_ref = (uintptr_t)ret_var.inner;
42657         if (ret_var.is_owned) {
42658                 ret_ref |= 1;
42659         }
42660         return ret_ref;
42661 }
42662
42663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42664         LDKRouteHintHop this_ptr_conv;
42665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42666         this_ptr_conv.is_owned = false;
42667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42668         LDKRoutingFees val_conv;
42669         val_conv.inner = (void*)(val & (~1));
42670         val_conv.is_owned = (val & 1) || (val == 0);
42671         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42672         val_conv = RoutingFees_clone(&val_conv);
42673         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42674 }
42675
42676 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42677         LDKRouteHintHop this_ptr_conv;
42678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42679         this_ptr_conv.is_owned = false;
42680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42681         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42682         return ret_conv;
42683 }
42684
42685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42686         LDKRouteHintHop this_ptr_conv;
42687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42688         this_ptr_conv.is_owned = false;
42689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42690         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42691 }
42692
42693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42694         LDKRouteHintHop this_ptr_conv;
42695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42696         this_ptr_conv.is_owned = false;
42697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42698         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42699         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42700         int64_t ret_ref = (uintptr_t)ret_copy;
42701         return ret_ref;
42702 }
42703
42704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42705         LDKRouteHintHop this_ptr_conv;
42706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42707         this_ptr_conv.is_owned = false;
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42709         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42710         CHECK_ACCESS(val_ptr);
42711         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42712         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42713         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42714 }
42715
42716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42717         LDKRouteHintHop this_ptr_conv;
42718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42719         this_ptr_conv.is_owned = false;
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42721         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42722         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42723         int64_t ret_ref = (uintptr_t)ret_copy;
42724         return ret_ref;
42725 }
42726
42727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42728         LDKRouteHintHop this_ptr_conv;
42729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42730         this_ptr_conv.is_owned = false;
42731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42732         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42733         CHECK_ACCESS(val_ptr);
42734         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42735         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42736         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42737 }
42738
42739 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) {
42740         LDKPublicKey src_node_id_arg_ref;
42741         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
42742         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
42743         LDKRoutingFees fees_arg_conv;
42744         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42745         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42746         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42747         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42748         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42749         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42750         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42751         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42752         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42753         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42754         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42755         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42756         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);
42757         int64_t ret_ref = 0;
42758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42761         ret_ref = (uintptr_t)ret_var.inner;
42762         if (ret_var.is_owned) {
42763                 ret_ref |= 1;
42764         }
42765         return ret_ref;
42766 }
42767
42768 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42769         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42770 int64_t ret_ref = 0;
42771 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42772 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42773 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42774 ret_ref = (uintptr_t)ret_var.inner;
42775 if (ret_var.is_owned) {
42776         ret_ref |= 1;
42777 }
42778         return ret_ref;
42779 }
42780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42781         LDKRouteHintHop arg_conv;
42782         arg_conv.inner = (void*)(arg & (~1));
42783         arg_conv.is_owned = false;
42784         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42785         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
42786         return ret_conv;
42787 }
42788
42789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42790         LDKRouteHintHop orig_conv;
42791         orig_conv.inner = (void*)(orig & (~1));
42792         orig_conv.is_owned = false;
42793         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42794         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42795         int64_t ret_ref = 0;
42796         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42797         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42799         ret_ref = (uintptr_t)ret_var.inner;
42800         if (ret_var.is_owned) {
42801                 ret_ref |= 1;
42802         }
42803         return ret_ref;
42804 }
42805
42806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
42807         LDKRouteHintHop o_conv;
42808         o_conv.inner = (void*)(o & (~1));
42809         o_conv.is_owned = false;
42810         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42811         int64_t ret_conv = RouteHintHop_hash(&o_conv);
42812         return ret_conv;
42813 }
42814
42815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42816         LDKRouteHintHop a_conv;
42817         a_conv.inner = (void*)(a & (~1));
42818         a_conv.is_owned = false;
42819         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42820         LDKRouteHintHop b_conv;
42821         b_conv.inner = (void*)(b & (~1));
42822         b_conv.is_owned = false;
42823         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42824         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
42825         return ret_conv;
42826 }
42827
42828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
42829         LDKRouteHintHop obj_conv;
42830         obj_conv.inner = (void*)(obj & (~1));
42831         obj_conv.is_owned = false;
42832         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42833         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42834         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42835         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42836         CVec_u8Z_free(ret_var);
42837         return ret_arr;
42838 }
42839
42840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42841         LDKu8slice ser_ref;
42842         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42843         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42844         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42845         *ret_conv = RouteHintHop_read(ser_ref);
42846         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42847         return (int64_t)ret_conv;
42848 }
42849
42850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
42851         LDKPublicKey our_node_pubkey_ref;
42852         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
42853         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
42854         LDKRouteParameters route_params_conv;
42855         route_params_conv.inner = (void*)(route_params & (~1));
42856         route_params_conv.is_owned = false;
42857         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42858         LDKNetworkGraph network_conv;
42859         network_conv.inner = (void*)(network & (~1));
42860         network_conv.is_owned = false;
42861         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
42862         LDKCVec_ChannelDetailsZ first_hops_constr;
42863         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42864         if (first_hops != NULL) {
42865                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
42866                 if (first_hops_constr.datalen > 0)
42867                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42868                 else
42869                         first_hops_constr.data = NULL;
42870                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
42871                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42872                         int64_t first_hops_conv_16 = first_hops_vals[q];
42873                         LDKChannelDetails first_hops_conv_16_conv;
42874                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42875                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42876                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42877                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42878                 }
42879                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
42880                 first_hops_ptr = &first_hops_constr;
42881         }
42882         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42883         CHECK_ACCESS(logger_ptr);
42884         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42885         if (logger_conv.free == LDKLogger_JCalls_free) {
42886                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42887                 LDKLogger_JCalls_cloned(&logger_conv);
42888         }
42889         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42890         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42891         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42892         unsigned char random_seed_bytes_arr[32];
42893         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
42894         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
42895         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42896         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42897         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
42898         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42899         return (int64_t)ret_conv;
42900 }
42901
42902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42903         if ((this_ptr & 1) != 0) return;
42904         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42905         CHECK_ACCESS(this_ptr_ptr);
42906         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42907         FREE((void*)this_ptr);
42908         Score_free(this_ptr_conv);
42909 }
42910
42911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42912         if ((this_ptr & 1) != 0) return;
42913         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42914         CHECK_ACCESS(this_ptr_ptr);
42915         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42916         FREE((void*)this_ptr);
42917         LockableScore_free(this_ptr_conv);
42918 }
42919
42920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42921         LDKMultiThreadedLockableScore this_obj_conv;
42922         this_obj_conv.inner = (void*)(this_obj & (~1));
42923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42925         MultiThreadedLockableScore_free(this_obj_conv);
42926 }
42927
42928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
42929         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42930         CHECK_ACCESS(score_ptr);
42931         LDKScore score_conv = *(LDKScore*)(score_ptr);
42932         if (score_conv.free == LDKScore_JCalls_free) {
42933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42934                 LDKScore_JCalls_cloned(&score_conv);
42935         }
42936         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42937         int64_t ret_ref = 0;
42938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42941         ret_ref = (uintptr_t)ret_var.inner;
42942         if (ret_var.is_owned) {
42943                 ret_ref |= 1;
42944         }
42945         return ret_ref;
42946 }
42947
42948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42949         LDKFixedPenaltyScorer this_obj_conv;
42950         this_obj_conv.inner = (void*)(this_obj & (~1));
42951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42953         FixedPenaltyScorer_free(this_obj_conv);
42954 }
42955
42956 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42957         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42958 int64_t ret_ref = 0;
42959 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42960 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42961 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42962 ret_ref = (uintptr_t)ret_var.inner;
42963 if (ret_var.is_owned) {
42964         ret_ref |= 1;
42965 }
42966         return ret_ref;
42967 }
42968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42969         LDKFixedPenaltyScorer arg_conv;
42970         arg_conv.inner = (void*)(arg & (~1));
42971         arg_conv.is_owned = false;
42972         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42973         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
42974         return ret_conv;
42975 }
42976
42977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42978         LDKFixedPenaltyScorer orig_conv;
42979         orig_conv.inner = (void*)(orig & (~1));
42980         orig_conv.is_owned = false;
42981         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42982         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42983         int64_t ret_ref = 0;
42984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42987         ret_ref = (uintptr_t)ret_var.inner;
42988         if (ret_var.is_owned) {
42989                 ret_ref |= 1;
42990         }
42991         return ret_ref;
42992 }
42993
42994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
42995         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42996         int64_t ret_ref = 0;
42997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43000         ret_ref = (uintptr_t)ret_var.inner;
43001         if (ret_var.is_owned) {
43002                 ret_ref |= 1;
43003         }
43004         return ret_ref;
43005 }
43006
43007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43008         LDKFixedPenaltyScorer this_arg_conv;
43009         this_arg_conv.inner = (void*)(this_arg & (~1));
43010         this_arg_conv.is_owned = false;
43011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43012         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43013         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
43014         return (int64_t)ret_ret;
43015 }
43016
43017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43018         LDKFixedPenaltyScorer obj_conv;
43019         obj_conv.inner = (void*)(obj & (~1));
43020         obj_conv.is_owned = false;
43021         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43022         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
43023         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43024         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43025         CVec_u8Z_free(ret_var);
43026         return ret_arr;
43027 }
43028
43029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
43030         LDKu8slice ser_ref;
43031         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43032         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43033         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
43034         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
43035         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43036         return (int64_t)ret_conv;
43037 }
43038
43039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43040         LDKScorer this_obj_conv;
43041         this_obj_conv.inner = (void*)(this_obj & (~1));
43042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43044         Scorer_free(this_obj_conv);
43045 }
43046
43047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43048         LDKScoringParameters this_obj_conv;
43049         this_obj_conv.inner = (void*)(this_obj & (~1));
43050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43052         ScoringParameters_free(this_obj_conv);
43053 }
43054
43055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43056         LDKScoringParameters this_ptr_conv;
43057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43058         this_ptr_conv.is_owned = false;
43059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43060         int64_t ret_conv = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43061         return ret_conv;
43062 }
43063
43064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43065         LDKScoringParameters this_ptr_conv;
43066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43067         this_ptr_conv.is_owned = false;
43068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43069         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43070 }
43071
43072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43073         LDKScoringParameters this_ptr_conv;
43074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43075         this_ptr_conv.is_owned = false;
43076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43077         int64_t ret_conv = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
43078         return ret_conv;
43079 }
43080
43081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43082         LDKScoringParameters this_ptr_conv;
43083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43084         this_ptr_conv.is_owned = false;
43085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43086         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
43087 }
43088
43089 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
43090         LDKScoringParameters this_ptr_conv;
43091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43092         this_ptr_conv.is_owned = false;
43093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43094         int16_t ret_conv = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
43095         return ret_conv;
43096 }
43097
43098 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) {
43099         LDKScoringParameters this_ptr_conv;
43100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43101         this_ptr_conv.is_owned = false;
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43103         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
43104 }
43105
43106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
43107         LDKScoringParameters this_ptr_conv;
43108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43109         this_ptr_conv.is_owned = false;
43110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43111         int64_t ret_conv = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
43112         return ret_conv;
43113 }
43114
43115 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) {
43116         LDKScoringParameters this_ptr_conv;
43117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43118         this_ptr_conv.is_owned = false;
43119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43120         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
43121 }
43122
43123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
43124         LDKScoringParameters this_ptr_conv;
43125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43126         this_ptr_conv.is_owned = false;
43127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43128         int64_t ret_conv = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
43129         return ret_conv;
43130 }
43131
43132 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) {
43133         LDKScoringParameters this_ptr_conv;
43134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43135         this_ptr_conv.is_owned = false;
43136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43137         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
43138 }
43139
43140 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) {
43141         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);
43142         int64_t ret_ref = 0;
43143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43146         ret_ref = (uintptr_t)ret_var.inner;
43147         if (ret_var.is_owned) {
43148                 ret_ref |= 1;
43149         }
43150         return ret_ref;
43151 }
43152
43153 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
43154         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
43155 int64_t ret_ref = 0;
43156 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43157 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43158 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43159 ret_ref = (uintptr_t)ret_var.inner;
43160 if (ret_var.is_owned) {
43161         ret_ref |= 1;
43162 }
43163         return ret_ref;
43164 }
43165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43166         LDKScoringParameters arg_conv;
43167         arg_conv.inner = (void*)(arg & (~1));
43168         arg_conv.is_owned = false;
43169         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43170         int64_t ret_conv = ScoringParameters_clone_ptr(&arg_conv);
43171         return ret_conv;
43172 }
43173
43174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43175         LDKScoringParameters orig_conv;
43176         orig_conv.inner = (void*)(orig & (~1));
43177         orig_conv.is_owned = false;
43178         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43179         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
43180         int64_t ret_ref = 0;
43181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43184         ret_ref = (uintptr_t)ret_var.inner;
43185         if (ret_var.is_owned) {
43186                 ret_ref |= 1;
43187         }
43188         return ret_ref;
43189 }
43190
43191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43192         LDKScoringParameters obj_conv;
43193         obj_conv.inner = (void*)(obj & (~1));
43194         obj_conv.is_owned = false;
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43196         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
43197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43199         CVec_u8Z_free(ret_var);
43200         return ret_arr;
43201 }
43202
43203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43204         LDKu8slice ser_ref;
43205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43207         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
43208         *ret_conv = ScoringParameters_read(ser_ref);
43209         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43210         return (int64_t)ret_conv;
43211 }
43212
43213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
43214         LDKScoringParameters params_conv;
43215         params_conv.inner = (void*)(params & (~1));
43216         params_conv.is_owned = (params & 1) || (params == 0);
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43218         params_conv = ScoringParameters_clone(&params_conv);
43219         LDKScorer ret_var = Scorer_new(params_conv);
43220         int64_t ret_ref = 0;
43221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43224         ret_ref = (uintptr_t)ret_var.inner;
43225         if (ret_var.is_owned) {
43226                 ret_ref |= 1;
43227         }
43228         return ret_ref;
43229 }
43230
43231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
43232         LDKScorer ret_var = Scorer_default();
43233         int64_t ret_ref = 0;
43234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43237         ret_ref = (uintptr_t)ret_var.inner;
43238         if (ret_var.is_owned) {
43239                 ret_ref |= 1;
43240         }
43241         return ret_ref;
43242 }
43243
43244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
43245         LDKScoringParameters ret_var = ScoringParameters_default();
43246         int64_t ret_ref = 0;
43247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43250         ret_ref = (uintptr_t)ret_var.inner;
43251         if (ret_var.is_owned) {
43252                 ret_ref |= 1;
43253         }
43254         return ret_ref;
43255 }
43256
43257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43258         LDKScorer this_arg_conv;
43259         this_arg_conv.inner = (void*)(this_arg & (~1));
43260         this_arg_conv.is_owned = false;
43261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43262         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43263         *ret_ret = Scorer_as_Score(&this_arg_conv);
43264         return (int64_t)ret_ret;
43265 }
43266
43267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43268         LDKScorer obj_conv;
43269         obj_conv.inner = (void*)(obj & (~1));
43270         obj_conv.is_owned = false;
43271         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43272         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
43273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43275         CVec_u8Z_free(ret_var);
43276         return ret_arr;
43277 }
43278
43279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43280         LDKu8slice ser_ref;
43281         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43282         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43283         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
43284         *ret_conv = Scorer_read(ser_ref);
43285         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43286         return (int64_t)ret_conv;
43287 }
43288
43289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43290         LDKProbabilisticScorer this_obj_conv;
43291         this_obj_conv.inner = (void*)(this_obj & (~1));
43292         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43294         ProbabilisticScorer_free(this_obj_conv);
43295 }
43296
43297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43298         LDKProbabilisticScoringParameters this_obj_conv;
43299         this_obj_conv.inner = (void*)(this_obj & (~1));
43300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43302         ProbabilisticScoringParameters_free(this_obj_conv);
43303 }
43304
43305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43306         LDKProbabilisticScoringParameters this_ptr_conv;
43307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43308         this_ptr_conv.is_owned = false;
43309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43310         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43311         return ret_conv;
43312 }
43313
43314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43315         LDKProbabilisticScoringParameters this_ptr_conv;
43316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43317         this_ptr_conv.is_owned = false;
43318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43319         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43320 }
43321
43322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43323         LDKProbabilisticScoringParameters this_ptr_conv;
43324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43325         this_ptr_conv.is_owned = false;
43326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43327         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
43328         return ret_conv;
43329 }
43330
43331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43332         LDKProbabilisticScoringParameters this_ptr_conv;
43333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43334         this_ptr_conv.is_owned = false;
43335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43336         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
43337 }
43338
43339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
43340         LDKProbabilisticScoringParameters this_ptr_conv;
43341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43342         this_ptr_conv.is_owned = false;
43343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43344         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
43345         return ret_conv;
43346 }
43347
43348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43349         LDKProbabilisticScoringParameters this_ptr_conv;
43350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43351         this_ptr_conv.is_owned = false;
43352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43353         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
43354 }
43355
43356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43357         LDKProbabilisticScoringParameters this_ptr_conv;
43358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43359         this_ptr_conv.is_owned = false;
43360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43361         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
43362         return ret_conv;
43363 }
43364
43365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43366         LDKProbabilisticScoringParameters this_ptr_conv;
43367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43368         this_ptr_conv.is_owned = false;
43369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43370         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
43371 }
43372
43373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg, int64_t amount_penalty_multiplier_msat_arg) {
43374         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
43375         int64_t ret_ref = 0;
43376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43379         ret_ref = (uintptr_t)ret_var.inner;
43380         if (ret_var.is_owned) {
43381                 ret_ref |= 1;
43382         }
43383         return ret_ref;
43384 }
43385
43386 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43387         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
43388 int64_t ret_ref = 0;
43389 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43390 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43391 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43392 ret_ref = (uintptr_t)ret_var.inner;
43393 if (ret_var.is_owned) {
43394         ret_ref |= 1;
43395 }
43396         return ret_ref;
43397 }
43398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43399         LDKProbabilisticScoringParameters arg_conv;
43400         arg_conv.inner = (void*)(arg & (~1));
43401         arg_conv.is_owned = false;
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43403         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43404         return ret_conv;
43405 }
43406
43407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43408         LDKProbabilisticScoringParameters orig_conv;
43409         orig_conv.inner = (void*)(orig & (~1));
43410         orig_conv.is_owned = false;
43411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43412         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
43413         int64_t ret_ref = 0;
43414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43417         ret_ref = (uintptr_t)ret_var.inner;
43418         if (ret_var.is_owned) {
43419                 ret_ref |= 1;
43420         }
43421         return ret_ref;
43422 }
43423
43424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph) {
43425         LDKProbabilisticScoringParameters params_conv;
43426         params_conv.inner = (void*)(params & (~1));
43427         params_conv.is_owned = (params & 1) || (params == 0);
43428         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43429         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43430         LDKNetworkGraph network_graph_conv;
43431         network_graph_conv.inner = (void*)(network_graph & (~1));
43432         network_graph_conv.is_owned = false;
43433         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43434         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
43435         int64_t ret_ref = 0;
43436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43439         ret_ref = (uintptr_t)ret_var.inner;
43440         if (ret_var.is_owned) {
43441                 ret_ref |= 1;
43442         }
43443         return ret_ref;
43444 }
43445
43446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
43447         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43448         int64_t ret_ref = 0;
43449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43452         ret_ref = (uintptr_t)ret_var.inner;
43453         if (ret_var.is_owned) {
43454                 ret_ref |= 1;
43455         }
43456         return ret_ref;
43457 }
43458
43459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43460         LDKProbabilisticScorer this_arg_conv;
43461         this_arg_conv.inner = (void*)(this_arg & (~1));
43462         this_arg_conv.is_owned = false;
43463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43464         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43465         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43466         return (int64_t)ret_ret;
43467 }
43468
43469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43470         LDKProbabilisticScorer obj_conv;
43471         obj_conv.inner = (void*)(obj & (~1));
43472         obj_conv.is_owned = false;
43473         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43474         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43477         CVec_u8Z_free(ret_var);
43478         return ret_arr;
43479 }
43480
43481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b) {
43482         LDKu8slice ser_ref;
43483         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43484         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43485         LDKProbabilisticScoringParameters arg_a_conv;
43486         arg_a_conv.inner = (void*)(arg_a & (~1));
43487         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
43488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43489         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43490         LDKNetworkGraph arg_b_conv;
43491         arg_b_conv.inner = (void*)(arg_b & (~1));
43492         arg_b_conv.is_owned = false;
43493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43494         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43495         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
43496         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43497         return (int64_t)ret_conv;
43498 }
43499
43500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43501         LDKFilesystemPersister this_obj_conv;
43502         this_obj_conv.inner = (void*)(this_obj & (~1));
43503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43505         FilesystemPersister_free(this_obj_conv);
43506 }
43507
43508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
43509         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
43510         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
43511         int64_t ret_ref = 0;
43512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43515         ret_ref = (uintptr_t)ret_var.inner;
43516         if (ret_var.is_owned) {
43517                 ret_ref |= 1;
43518         }
43519         return ret_ref;
43520 }
43521
43522 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
43523         LDKFilesystemPersister this_arg_conv;
43524         this_arg_conv.inner = (void*)(this_arg & (~1));
43525         this_arg_conv.is_owned = false;
43526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43527         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
43528         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
43529         Str_free(ret_str);
43530         return ret_conv;
43531 }
43532
43533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
43534         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
43535         LDKChannelManager manager_conv;
43536         manager_conv.inner = (void*)(manager & (~1));
43537         manager_conv.is_owned = false;
43538         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
43539         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43540         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
43541         return (int64_t)ret_conv;
43542 }
43543
43544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1network_1graph(JNIEnv *env, jclass clz, jstring data_dir, int64_t network_graph) {
43545         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
43546         LDKNetworkGraph network_graph_conv;
43547         network_graph_conv.inner = (void*)(network_graph & (~1));
43548         network_graph_conv.is_owned = false;
43549         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43550         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43551         *ret_conv = FilesystemPersister_persist_network_graph(data_dir_conv, &network_graph_conv);
43552         return (int64_t)ret_conv;
43553 }
43554
43555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
43556         LDKFilesystemPersister this_arg_conv;
43557         this_arg_conv.inner = (void*)(this_arg & (~1));
43558         this_arg_conv.is_owned = false;
43559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43560         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
43561         CHECK_ACCESS(keys_manager_ptr);
43562         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
43563         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
43564                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43565                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
43566         }
43567         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
43568         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
43569         return (int64_t)ret_conv;
43570 }
43571
43572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
43573         LDKFilesystemPersister this_arg_conv;
43574         this_arg_conv.inner = (void*)(this_arg & (~1));
43575         this_arg_conv.is_owned = false;
43576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43577         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
43578         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
43579         return (int64_t)ret_ret;
43580 }
43581
43582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43583         LDKBackgroundProcessor this_obj_conv;
43584         this_obj_conv.inner = (void*)(this_obj & (~1));
43585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43587         BackgroundProcessor_free(this_obj_conv);
43588 }
43589
43590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43591         if ((this_ptr & 1) != 0) return;
43592         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43593         CHECK_ACCESS(this_ptr_ptr);
43594         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
43595         FREE((void*)this_ptr);
43596         Persister_free(this_ptr_conv);
43597 }
43598
43599 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) {
43600         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
43601         CHECK_ACCESS(persister_ptr);
43602         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
43603         if (persister_conv.free == LDKPersister_JCalls_free) {
43604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43605                 LDKPersister_JCalls_cloned(&persister_conv);
43606         }
43607         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
43608         CHECK_ACCESS(event_handler_ptr);
43609         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
43610         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
43611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43612                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
43613         }
43614         LDKChainMonitor chain_monitor_conv;
43615         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
43616         chain_monitor_conv.is_owned = false;
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
43618         LDKChannelManager channel_manager_conv;
43619         channel_manager_conv.inner = (void*)(channel_manager & (~1));
43620         channel_manager_conv.is_owned = false;
43621         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
43622         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
43623         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
43624         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
43625         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
43626         LDKPeerManager peer_manager_conv;
43627         peer_manager_conv.inner = (void*)(peer_manager & (~1));
43628         peer_manager_conv.is_owned = false;
43629         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
43630         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43631         CHECK_ACCESS(logger_ptr);
43632         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43633         if (logger_conv.free == LDKLogger_JCalls_free) {
43634                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43635                 LDKLogger_JCalls_cloned(&logger_conv);
43636         }
43637         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);
43638         int64_t ret_ref = 0;
43639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43642         ret_ref = (uintptr_t)ret_var.inner;
43643         if (ret_var.is_owned) {
43644                 ret_ref |= 1;
43645         }
43646         return ret_ref;
43647 }
43648
43649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
43650         LDKBackgroundProcessor this_arg_conv;
43651         this_arg_conv.inner = (void*)(this_arg & (~1));
43652         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43654         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43655         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43656         *ret_conv = BackgroundProcessor_join(this_arg_conv);
43657         return (int64_t)ret_conv;
43658 }
43659
43660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
43661         LDKBackgroundProcessor this_arg_conv;
43662         this_arg_conv.inner = (void*)(this_arg & (~1));
43663         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43665         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43666         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43667         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
43668         return (int64_t)ret_conv;
43669 }
43670
43671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43672         if ((this_ptr & 1) != 0) return;
43673         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43674         CHECK_ACCESS(this_ptr_ptr);
43675         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43676         FREE((void*)this_ptr);
43677         ParseError_free(this_ptr_conv);
43678 }
43679
43680 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43681         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43682         *ret_copy = ParseError_clone(arg);
43683 int64_t ret_ref = (uintptr_t)ret_copy;
43684         return ret_ref;
43685 }
43686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43687         LDKParseError* arg_conv = (LDKParseError*)arg;
43688         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
43689         return ret_conv;
43690 }
43691
43692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43693         LDKParseError* orig_conv = (LDKParseError*)orig;
43694         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43695         *ret_copy = ParseError_clone(orig_conv);
43696         int64_t ret_ref = (uintptr_t)ret_copy;
43697         return ret_ref;
43698 }
43699
43700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
43701         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43702         CHECK_ACCESS(a_ptr);
43703         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43704         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
43705         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43706         *ret_copy = ParseError_bech32_error(a_conv);
43707         int64_t ret_ref = (uintptr_t)ret_copy;
43708         return ret_ref;
43709 }
43710
43711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
43712         
43713         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43714         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43715         int64_t ret_ref = (uintptr_t)ret_copy;
43716         return ret_ref;
43717 }
43718
43719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
43720         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
43721         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43722         *ret_copy = ParseError_malformed_signature(a_conv);
43723         int64_t ret_ref = (uintptr_t)ret_copy;
43724         return ret_ref;
43725 }
43726
43727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
43728         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43729         *ret_copy = ParseError_bad_prefix();
43730         int64_t ret_ref = (uintptr_t)ret_copy;
43731         return ret_ref;
43732 }
43733
43734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
43735         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43736         *ret_copy = ParseError_unknown_currency();
43737         int64_t ret_ref = (uintptr_t)ret_copy;
43738         return ret_ref;
43739 }
43740
43741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
43742         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43743         *ret_copy = ParseError_unknown_si_prefix();
43744         int64_t ret_ref = (uintptr_t)ret_copy;
43745         return ret_ref;
43746 }
43747
43748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
43749         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43750         *ret_copy = ParseError_malformed_hrp();
43751         int64_t ret_ref = (uintptr_t)ret_copy;
43752         return ret_ref;
43753 }
43754
43755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
43756         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43757         *ret_copy = ParseError_too_short_data_part();
43758         int64_t ret_ref = (uintptr_t)ret_copy;
43759         return ret_ref;
43760 }
43761
43762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
43763         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43764         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43765         int64_t ret_ref = (uintptr_t)ret_copy;
43766         return ret_ref;
43767 }
43768
43769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
43770         
43771         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43772         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43773         int64_t ret_ref = (uintptr_t)ret_copy;
43774         return ret_ref;
43775 }
43776
43777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
43778         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43779         *ret_copy = ParseError_padding_error();
43780         int64_t ret_ref = (uintptr_t)ret_copy;
43781         return ret_ref;
43782 }
43783
43784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
43785         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43786         *ret_copy = ParseError_integer_overflow_error();
43787         int64_t ret_ref = (uintptr_t)ret_copy;
43788         return ret_ref;
43789 }
43790
43791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
43792         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43793         *ret_copy = ParseError_invalid_seg_wit_program_length();
43794         int64_t ret_ref = (uintptr_t)ret_copy;
43795         return ret_ref;
43796 }
43797
43798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
43799         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43800         *ret_copy = ParseError_invalid_pub_key_hash_length();
43801         int64_t ret_ref = (uintptr_t)ret_copy;
43802         return ret_ref;
43803 }
43804
43805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
43806         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43807         *ret_copy = ParseError_invalid_script_hash_length();
43808         int64_t ret_ref = (uintptr_t)ret_copy;
43809         return ret_ref;
43810 }
43811
43812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
43813         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43814         *ret_copy = ParseError_invalid_recovery_id();
43815         int64_t ret_ref = (uintptr_t)ret_copy;
43816         return ret_ref;
43817 }
43818
43819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
43820         LDKStr a_conv = java_to_owned_str(env, a);
43821         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43822         *ret_copy = ParseError_invalid_slice_length(a_conv);
43823         int64_t ret_ref = (uintptr_t)ret_copy;
43824         return ret_ref;
43825 }
43826
43827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
43828         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43829         *ret_copy = ParseError_skip();
43830         int64_t ret_ref = (uintptr_t)ret_copy;
43831         return ret_ref;
43832 }
43833
43834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43835         if ((this_ptr & 1) != 0) return;
43836         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43837         CHECK_ACCESS(this_ptr_ptr);
43838         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43839         FREE((void*)this_ptr);
43840         ParseOrSemanticError_free(this_ptr_conv);
43841 }
43842
43843 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43844         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43845         *ret_copy = ParseOrSemanticError_clone(arg);
43846 int64_t ret_ref = (uintptr_t)ret_copy;
43847         return ret_ref;
43848 }
43849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43850         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
43851         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
43852         return ret_conv;
43853 }
43854
43855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43856         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
43857         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43858         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43859         int64_t ret_ref = (uintptr_t)ret_copy;
43860         return ret_ref;
43861 }
43862
43863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
43864         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43865         CHECK_ACCESS(a_ptr);
43866         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43867         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
43868         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43869         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43870         int64_t ret_ref = (uintptr_t)ret_copy;
43871         return ret_ref;
43872 }
43873
43874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
43875         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
43876         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43877         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43878         int64_t ret_ref = (uintptr_t)ret_copy;
43879         return ret_ref;
43880 }
43881
43882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43883         LDKInvoice this_obj_conv;
43884         this_obj_conv.inner = (void*)(this_obj & (~1));
43885         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43887         Invoice_free(this_obj_conv);
43888 }
43889
43890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43891         LDKInvoice a_conv;
43892         a_conv.inner = (void*)(a & (~1));
43893         a_conv.is_owned = false;
43894         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43895         LDKInvoice b_conv;
43896         b_conv.inner = (void*)(b & (~1));
43897         b_conv.is_owned = false;
43898         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43899         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
43900         return ret_conv;
43901 }
43902
43903 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43904         LDKInvoice ret_var = Invoice_clone(arg);
43905 int64_t ret_ref = 0;
43906 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43907 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43909 ret_ref = (uintptr_t)ret_var.inner;
43910 if (ret_var.is_owned) {
43911         ret_ref |= 1;
43912 }
43913         return ret_ref;
43914 }
43915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43916         LDKInvoice arg_conv;
43917         arg_conv.inner = (void*)(arg & (~1));
43918         arg_conv.is_owned = false;
43919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43920         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
43921         return ret_conv;
43922 }
43923
43924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43925         LDKInvoice orig_conv;
43926         orig_conv.inner = (void*)(orig & (~1));
43927         orig_conv.is_owned = false;
43928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43929         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43930         int64_t ret_ref = 0;
43931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43934         ret_ref = (uintptr_t)ret_var.inner;
43935         if (ret_var.is_owned) {
43936                 ret_ref |= 1;
43937         }
43938         return ret_ref;
43939 }
43940
43941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43942         LDKSignedRawInvoice this_obj_conv;
43943         this_obj_conv.inner = (void*)(this_obj & (~1));
43944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43946         SignedRawInvoice_free(this_obj_conv);
43947 }
43948
43949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43950         LDKSignedRawInvoice a_conv;
43951         a_conv.inner = (void*)(a & (~1));
43952         a_conv.is_owned = false;
43953         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43954         LDKSignedRawInvoice b_conv;
43955         b_conv.inner = (void*)(b & (~1));
43956         b_conv.is_owned = false;
43957         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43958         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
43959         return ret_conv;
43960 }
43961
43962 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43963         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43964 int64_t ret_ref = 0;
43965 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43966 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43967 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43968 ret_ref = (uintptr_t)ret_var.inner;
43969 if (ret_var.is_owned) {
43970         ret_ref |= 1;
43971 }
43972         return ret_ref;
43973 }
43974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43975         LDKSignedRawInvoice arg_conv;
43976         arg_conv.inner = (void*)(arg & (~1));
43977         arg_conv.is_owned = false;
43978         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43979         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
43980         return ret_conv;
43981 }
43982
43983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43984         LDKSignedRawInvoice orig_conv;
43985         orig_conv.inner = (void*)(orig & (~1));
43986         orig_conv.is_owned = false;
43987         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43988         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43989         int64_t ret_ref = 0;
43990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43993         ret_ref = (uintptr_t)ret_var.inner;
43994         if (ret_var.is_owned) {
43995                 ret_ref |= 1;
43996         }
43997         return ret_ref;
43998 }
43999
44000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44001         LDKRawInvoice this_obj_conv;
44002         this_obj_conv.inner = (void*)(this_obj & (~1));
44003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44005         RawInvoice_free(this_obj_conv);
44006 }
44007
44008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
44009         LDKRawInvoice this_ptr_conv;
44010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44011         this_ptr_conv.is_owned = false;
44012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44013         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
44014         int64_t ret_ref = 0;
44015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44018         ret_ref = (uintptr_t)ret_var.inner;
44019         if (ret_var.is_owned) {
44020                 ret_ref |= 1;
44021         }
44022         return ret_ref;
44023 }
44024
44025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44026         LDKRawInvoice this_ptr_conv;
44027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44028         this_ptr_conv.is_owned = false;
44029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44030         LDKRawDataPart val_conv;
44031         val_conv.inner = (void*)(val & (~1));
44032         val_conv.is_owned = (val & 1) || (val == 0);
44033         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44034         val_conv = RawDataPart_clone(&val_conv);
44035         RawInvoice_set_data(&this_ptr_conv, val_conv);
44036 }
44037
44038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44039         LDKRawInvoice a_conv;
44040         a_conv.inner = (void*)(a & (~1));
44041         a_conv.is_owned = false;
44042         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44043         LDKRawInvoice b_conv;
44044         b_conv.inner = (void*)(b & (~1));
44045         b_conv.is_owned = false;
44046         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44047         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
44048         return ret_conv;
44049 }
44050
44051 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
44052         LDKRawInvoice ret_var = RawInvoice_clone(arg);
44053 int64_t ret_ref = 0;
44054 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44055 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44056 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44057 ret_ref = (uintptr_t)ret_var.inner;
44058 if (ret_var.is_owned) {
44059         ret_ref |= 1;
44060 }
44061         return ret_ref;
44062 }
44063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44064         LDKRawInvoice arg_conv;
44065         arg_conv.inner = (void*)(arg & (~1));
44066         arg_conv.is_owned = false;
44067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44068         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
44069         return ret_conv;
44070 }
44071
44072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44073         LDKRawInvoice orig_conv;
44074         orig_conv.inner = (void*)(orig & (~1));
44075         orig_conv.is_owned = false;
44076         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44077         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
44078         int64_t ret_ref = 0;
44079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44082         ret_ref = (uintptr_t)ret_var.inner;
44083         if (ret_var.is_owned) {
44084                 ret_ref |= 1;
44085         }
44086         return ret_ref;
44087 }
44088
44089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44090         LDKRawDataPart this_obj_conv;
44091         this_obj_conv.inner = (void*)(this_obj & (~1));
44092         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44094         RawDataPart_free(this_obj_conv);
44095 }
44096
44097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
44098         LDKRawDataPart this_ptr_conv;
44099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44100         this_ptr_conv.is_owned = false;
44101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44102         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
44103         int64_t ret_ref = 0;
44104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44107         ret_ref = (uintptr_t)ret_var.inner;
44108         if (ret_var.is_owned) {
44109                 ret_ref |= 1;
44110         }
44111         return ret_ref;
44112 }
44113
44114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44115         LDKRawDataPart this_ptr_conv;
44116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44117         this_ptr_conv.is_owned = false;
44118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44119         LDKPositiveTimestamp val_conv;
44120         val_conv.inner = (void*)(val & (~1));
44121         val_conv.is_owned = (val & 1) || (val == 0);
44122         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44123         val_conv = PositiveTimestamp_clone(&val_conv);
44124         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
44125 }
44126
44127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44128         LDKRawDataPart a_conv;
44129         a_conv.inner = (void*)(a & (~1));
44130         a_conv.is_owned = false;
44131         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44132         LDKRawDataPart b_conv;
44133         b_conv.inner = (void*)(b & (~1));
44134         b_conv.is_owned = false;
44135         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44136         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
44137         return ret_conv;
44138 }
44139
44140 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
44141         LDKRawDataPart ret_var = RawDataPart_clone(arg);
44142 int64_t ret_ref = 0;
44143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44146 ret_ref = (uintptr_t)ret_var.inner;
44147 if (ret_var.is_owned) {
44148         ret_ref |= 1;
44149 }
44150         return ret_ref;
44151 }
44152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44153         LDKRawDataPart arg_conv;
44154         arg_conv.inner = (void*)(arg & (~1));
44155         arg_conv.is_owned = false;
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44157         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
44158         return ret_conv;
44159 }
44160
44161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44162         LDKRawDataPart orig_conv;
44163         orig_conv.inner = (void*)(orig & (~1));
44164         orig_conv.is_owned = false;
44165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44166         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
44167         int64_t ret_ref = 0;
44168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44171         ret_ref = (uintptr_t)ret_var.inner;
44172         if (ret_var.is_owned) {
44173                 ret_ref |= 1;
44174         }
44175         return ret_ref;
44176 }
44177
44178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44179         LDKPositiveTimestamp this_obj_conv;
44180         this_obj_conv.inner = (void*)(this_obj & (~1));
44181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44183         PositiveTimestamp_free(this_obj_conv);
44184 }
44185
44186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44187         LDKPositiveTimestamp a_conv;
44188         a_conv.inner = (void*)(a & (~1));
44189         a_conv.is_owned = false;
44190         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44191         LDKPositiveTimestamp b_conv;
44192         b_conv.inner = (void*)(b & (~1));
44193         b_conv.is_owned = false;
44194         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44195         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
44196         return ret_conv;
44197 }
44198
44199 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
44200         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
44201 int64_t ret_ref = 0;
44202 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44203 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44204 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44205 ret_ref = (uintptr_t)ret_var.inner;
44206 if (ret_var.is_owned) {
44207         ret_ref |= 1;
44208 }
44209         return ret_ref;
44210 }
44211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44212         LDKPositiveTimestamp arg_conv;
44213         arg_conv.inner = (void*)(arg & (~1));
44214         arg_conv.is_owned = false;
44215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44216         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
44217         return ret_conv;
44218 }
44219
44220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44221         LDKPositiveTimestamp orig_conv;
44222         orig_conv.inner = (void*)(orig & (~1));
44223         orig_conv.is_owned = false;
44224         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44225         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
44226         int64_t ret_ref = 0;
44227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44230         ret_ref = (uintptr_t)ret_var.inner;
44231         if (ret_var.is_owned) {
44232                 ret_ref |= 1;
44233         }
44234         return ret_ref;
44235 }
44236
44237 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44238         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
44239         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
44240         return ret_conv;
44241 }
44242
44243 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
44244         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
44245         return ret_conv;
44246 }
44247
44248 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
44249         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
44250         return ret_conv;
44251 }
44252
44253 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
44254         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
44255         return ret_conv;
44256 }
44257
44258 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
44259         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
44260         return ret_conv;
44261 }
44262
44263 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44264         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
44265         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
44266         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
44267         return ret_conv;
44268 }
44269
44270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
44271         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
44272         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
44273         return ret_conv;
44274 }
44275
44276 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44277         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
44278         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
44279         return ret_conv;
44280 }
44281
44282 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
44283         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
44284         return ret_conv;
44285 }
44286
44287 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
44288         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
44289         return ret_conv;
44290 }
44291
44292 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
44293         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
44294         return ret_conv;
44295 }
44296
44297 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
44298         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
44299         return ret_conv;
44300 }
44301
44302 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
44303         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
44304         return ret_conv;
44305 }
44306
44307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
44308         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44309         int64_t ret_conv = Currency_hash(o_conv);
44310         return ret_conv;
44311 }
44312
44313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44314         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
44315         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
44316         jboolean ret_conv = Currency_eq(a_conv, b_conv);
44317         return ret_conv;
44318 }
44319
44320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44321         LDKSha256 this_obj_conv;
44322         this_obj_conv.inner = (void*)(this_obj & (~1));
44323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44325         Sha256_free(this_obj_conv);
44326 }
44327
44328 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
44329         LDKSha256 ret_var = Sha256_clone(arg);
44330 int64_t ret_ref = 0;
44331 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44332 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44333 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44334 ret_ref = (uintptr_t)ret_var.inner;
44335 if (ret_var.is_owned) {
44336         ret_ref |= 1;
44337 }
44338         return ret_ref;
44339 }
44340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44341         LDKSha256 arg_conv;
44342         arg_conv.inner = (void*)(arg & (~1));
44343         arg_conv.is_owned = false;
44344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44345         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
44346         return ret_conv;
44347 }
44348
44349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44350         LDKSha256 orig_conv;
44351         orig_conv.inner = (void*)(orig & (~1));
44352         orig_conv.is_owned = false;
44353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44354         LDKSha256 ret_var = Sha256_clone(&orig_conv);
44355         int64_t ret_ref = 0;
44356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44359         ret_ref = (uintptr_t)ret_var.inner;
44360         if (ret_var.is_owned) {
44361                 ret_ref |= 1;
44362         }
44363         return ret_ref;
44364 }
44365
44366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
44367         LDKSha256 o_conv;
44368         o_conv.inner = (void*)(o & (~1));
44369         o_conv.is_owned = false;
44370         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44371         int64_t ret_conv = Sha256_hash(&o_conv);
44372         return ret_conv;
44373 }
44374
44375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44376         LDKSha256 a_conv;
44377         a_conv.inner = (void*)(a & (~1));
44378         a_conv.is_owned = false;
44379         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44380         LDKSha256 b_conv;
44381         b_conv.inner = (void*)(b & (~1));
44382         b_conv.is_owned = false;
44383         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44384         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
44385         return ret_conv;
44386 }
44387
44388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44389         LDKDescription this_obj_conv;
44390         this_obj_conv.inner = (void*)(this_obj & (~1));
44391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44393         Description_free(this_obj_conv);
44394 }
44395
44396 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
44397         LDKDescription ret_var = Description_clone(arg);
44398 int64_t ret_ref = 0;
44399 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44400 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44401 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44402 ret_ref = (uintptr_t)ret_var.inner;
44403 if (ret_var.is_owned) {
44404         ret_ref |= 1;
44405 }
44406         return ret_ref;
44407 }
44408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44409         LDKDescription arg_conv;
44410         arg_conv.inner = (void*)(arg & (~1));
44411         arg_conv.is_owned = false;
44412         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44413         int64_t ret_conv = Description_clone_ptr(&arg_conv);
44414         return ret_conv;
44415 }
44416
44417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44418         LDKDescription orig_conv;
44419         orig_conv.inner = (void*)(orig & (~1));
44420         orig_conv.is_owned = false;
44421         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44422         LDKDescription ret_var = Description_clone(&orig_conv);
44423         int64_t ret_ref = 0;
44424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44427         ret_ref = (uintptr_t)ret_var.inner;
44428         if (ret_var.is_owned) {
44429                 ret_ref |= 1;
44430         }
44431         return ret_ref;
44432 }
44433
44434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
44435         LDKDescription o_conv;
44436         o_conv.inner = (void*)(o & (~1));
44437         o_conv.is_owned = false;
44438         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44439         int64_t ret_conv = Description_hash(&o_conv);
44440         return ret_conv;
44441 }
44442
44443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44444         LDKDescription a_conv;
44445         a_conv.inner = (void*)(a & (~1));
44446         a_conv.is_owned = false;
44447         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44448         LDKDescription b_conv;
44449         b_conv.inner = (void*)(b & (~1));
44450         b_conv.is_owned = false;
44451         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44452         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
44453         return ret_conv;
44454 }
44455
44456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44457         LDKPayeePubKey this_obj_conv;
44458         this_obj_conv.inner = (void*)(this_obj & (~1));
44459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44461         PayeePubKey_free(this_obj_conv);
44462 }
44463
44464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44465         LDKPayeePubKey this_ptr_conv;
44466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44467         this_ptr_conv.is_owned = false;
44468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44469         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
44471         return ret_arr;
44472 }
44473
44474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44475         LDKPayeePubKey this_ptr_conv;
44476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44477         this_ptr_conv.is_owned = false;
44478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44479         LDKPublicKey val_ref;
44480         CHECK((*env)->GetArrayLength(env, val) == 33);
44481         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44482         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44483 }
44484
44485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44486         LDKPublicKey a_arg_ref;
44487         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
44488         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
44489         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44490         int64_t ret_ref = 0;
44491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44494         ret_ref = (uintptr_t)ret_var.inner;
44495         if (ret_var.is_owned) {
44496                 ret_ref |= 1;
44497         }
44498         return ret_ref;
44499 }
44500
44501 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44502         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44503 int64_t ret_ref = 0;
44504 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44505 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44506 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44507 ret_ref = (uintptr_t)ret_var.inner;
44508 if (ret_var.is_owned) {
44509         ret_ref |= 1;
44510 }
44511         return ret_ref;
44512 }
44513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44514         LDKPayeePubKey arg_conv;
44515         arg_conv.inner = (void*)(arg & (~1));
44516         arg_conv.is_owned = false;
44517         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44518         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
44519         return ret_conv;
44520 }
44521
44522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44523         LDKPayeePubKey orig_conv;
44524         orig_conv.inner = (void*)(orig & (~1));
44525         orig_conv.is_owned = false;
44526         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44527         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44528         int64_t ret_ref = 0;
44529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44532         ret_ref = (uintptr_t)ret_var.inner;
44533         if (ret_var.is_owned) {
44534                 ret_ref |= 1;
44535         }
44536         return ret_ref;
44537 }
44538
44539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
44540         LDKPayeePubKey o_conv;
44541         o_conv.inner = (void*)(o & (~1));
44542         o_conv.is_owned = false;
44543         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44544         int64_t ret_conv = PayeePubKey_hash(&o_conv);
44545         return ret_conv;
44546 }
44547
44548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44549         LDKPayeePubKey a_conv;
44550         a_conv.inner = (void*)(a & (~1));
44551         a_conv.is_owned = false;
44552         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44553         LDKPayeePubKey b_conv;
44554         b_conv.inner = (void*)(b & (~1));
44555         b_conv.is_owned = false;
44556         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44557         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
44558         return ret_conv;
44559 }
44560
44561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44562         LDKExpiryTime this_obj_conv;
44563         this_obj_conv.inner = (void*)(this_obj & (~1));
44564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44566         ExpiryTime_free(this_obj_conv);
44567 }
44568
44569 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44570         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44571 int64_t ret_ref = 0;
44572 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44573 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44574 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44575 ret_ref = (uintptr_t)ret_var.inner;
44576 if (ret_var.is_owned) {
44577         ret_ref |= 1;
44578 }
44579         return ret_ref;
44580 }
44581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44582         LDKExpiryTime arg_conv;
44583         arg_conv.inner = (void*)(arg & (~1));
44584         arg_conv.is_owned = false;
44585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44586         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
44587         return ret_conv;
44588 }
44589
44590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44591         LDKExpiryTime orig_conv;
44592         orig_conv.inner = (void*)(orig & (~1));
44593         orig_conv.is_owned = false;
44594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44595         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44596         int64_t ret_ref = 0;
44597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44600         ret_ref = (uintptr_t)ret_var.inner;
44601         if (ret_var.is_owned) {
44602                 ret_ref |= 1;
44603         }
44604         return ret_ref;
44605 }
44606
44607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
44608         LDKExpiryTime o_conv;
44609         o_conv.inner = (void*)(o & (~1));
44610         o_conv.is_owned = false;
44611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44612         int64_t ret_conv = ExpiryTime_hash(&o_conv);
44613         return ret_conv;
44614 }
44615
44616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44617         LDKExpiryTime a_conv;
44618         a_conv.inner = (void*)(a & (~1));
44619         a_conv.is_owned = false;
44620         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44621         LDKExpiryTime b_conv;
44622         b_conv.inner = (void*)(b & (~1));
44623         b_conv.is_owned = false;
44624         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44625         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
44626         return ret_conv;
44627 }
44628
44629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44630         LDKMinFinalCltvExpiry this_obj_conv;
44631         this_obj_conv.inner = (void*)(this_obj & (~1));
44632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44634         MinFinalCltvExpiry_free(this_obj_conv);
44635 }
44636
44637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44638         LDKMinFinalCltvExpiry this_ptr_conv;
44639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44640         this_ptr_conv.is_owned = false;
44641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44642         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44643         return ret_conv;
44644 }
44645
44646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44647         LDKMinFinalCltvExpiry this_ptr_conv;
44648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44649         this_ptr_conv.is_owned = false;
44650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44651         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44652 }
44653
44654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
44655         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44656         int64_t ret_ref = 0;
44657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44660         ret_ref = (uintptr_t)ret_var.inner;
44661         if (ret_var.is_owned) {
44662                 ret_ref |= 1;
44663         }
44664         return ret_ref;
44665 }
44666
44667 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44668         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44669 int64_t ret_ref = 0;
44670 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44671 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44672 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44673 ret_ref = (uintptr_t)ret_var.inner;
44674 if (ret_var.is_owned) {
44675         ret_ref |= 1;
44676 }
44677         return ret_ref;
44678 }
44679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44680         LDKMinFinalCltvExpiry arg_conv;
44681         arg_conv.inner = (void*)(arg & (~1));
44682         arg_conv.is_owned = false;
44683         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44684         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44685         return ret_conv;
44686 }
44687
44688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44689         LDKMinFinalCltvExpiry orig_conv;
44690         orig_conv.inner = (void*)(orig & (~1));
44691         orig_conv.is_owned = false;
44692         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44693         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44694         int64_t ret_ref = 0;
44695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44698         ret_ref = (uintptr_t)ret_var.inner;
44699         if (ret_var.is_owned) {
44700                 ret_ref |= 1;
44701         }
44702         return ret_ref;
44703 }
44704
44705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
44706         LDKMinFinalCltvExpiry o_conv;
44707         o_conv.inner = (void*)(o & (~1));
44708         o_conv.is_owned = false;
44709         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44710         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
44711         return ret_conv;
44712 }
44713
44714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44715         LDKMinFinalCltvExpiry a_conv;
44716         a_conv.inner = (void*)(a & (~1));
44717         a_conv.is_owned = false;
44718         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44719         LDKMinFinalCltvExpiry b_conv;
44720         b_conv.inner = (void*)(b & (~1));
44721         b_conv.is_owned = false;
44722         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44723         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44724         return ret_conv;
44725 }
44726
44727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44728         if ((this_ptr & 1) != 0) return;
44729         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44730         CHECK_ACCESS(this_ptr_ptr);
44731         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44732         FREE((void*)this_ptr);
44733         Fallback_free(this_ptr_conv);
44734 }
44735
44736 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44737         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44738         *ret_copy = Fallback_clone(arg);
44739 int64_t ret_ref = (uintptr_t)ret_copy;
44740         return ret_ref;
44741 }
44742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44743         LDKFallback* arg_conv = (LDKFallback*)arg;
44744         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
44745         return ret_conv;
44746 }
44747
44748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44749         LDKFallback* orig_conv = (LDKFallback*)orig;
44750         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44751         *ret_copy = Fallback_clone(orig_conv);
44752         int64_t ret_ref = (uintptr_t)ret_copy;
44753         return ret_ref;
44754 }
44755
44756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
44757         
44758         LDKCVec_u8Z program_ref;
44759         program_ref.datalen = (*env)->GetArrayLength(env, program);
44760         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44761         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
44762         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44763         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44764         int64_t ret_ref = (uintptr_t)ret_copy;
44765         return ret_ref;
44766 }
44767
44768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
44769         LDKTwentyBytes a_ref;
44770         CHECK((*env)->GetArrayLength(env, a) == 20);
44771         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
44772         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44773         *ret_copy = Fallback_pub_key_hash(a_ref);
44774         int64_t ret_ref = (uintptr_t)ret_copy;
44775         return ret_ref;
44776 }
44777
44778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
44779         LDKTwentyBytes a_ref;
44780         CHECK((*env)->GetArrayLength(env, a) == 20);
44781         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
44782         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44783         *ret_copy = Fallback_script_hash(a_ref);
44784         int64_t ret_ref = (uintptr_t)ret_copy;
44785         return ret_ref;
44786 }
44787
44788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
44789         LDKFallback* o_conv = (LDKFallback*)o;
44790         int64_t ret_conv = Fallback_hash(o_conv);
44791         return ret_conv;
44792 }
44793
44794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44795         LDKFallback* a_conv = (LDKFallback*)a;
44796         LDKFallback* b_conv = (LDKFallback*)b;
44797         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
44798         return ret_conv;
44799 }
44800
44801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44802         LDKInvoiceSignature this_obj_conv;
44803         this_obj_conv.inner = (void*)(this_obj & (~1));
44804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44806         InvoiceSignature_free(this_obj_conv);
44807 }
44808
44809 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44810         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44811 int64_t ret_ref = 0;
44812 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44813 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44814 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44815 ret_ref = (uintptr_t)ret_var.inner;
44816 if (ret_var.is_owned) {
44817         ret_ref |= 1;
44818 }
44819         return ret_ref;
44820 }
44821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44822         LDKInvoiceSignature arg_conv;
44823         arg_conv.inner = (void*)(arg & (~1));
44824         arg_conv.is_owned = false;
44825         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44826         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
44827         return ret_conv;
44828 }
44829
44830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44831         LDKInvoiceSignature orig_conv;
44832         orig_conv.inner = (void*)(orig & (~1));
44833         orig_conv.is_owned = false;
44834         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44835         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44836         int64_t ret_ref = 0;
44837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44840         ret_ref = (uintptr_t)ret_var.inner;
44841         if (ret_var.is_owned) {
44842                 ret_ref |= 1;
44843         }
44844         return ret_ref;
44845 }
44846
44847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44848         LDKInvoiceSignature a_conv;
44849         a_conv.inner = (void*)(a & (~1));
44850         a_conv.is_owned = false;
44851         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44852         LDKInvoiceSignature b_conv;
44853         b_conv.inner = (void*)(b & (~1));
44854         b_conv.is_owned = false;
44855         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44856         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
44857         return ret_conv;
44858 }
44859
44860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44861         LDKPrivateRoute this_obj_conv;
44862         this_obj_conv.inner = (void*)(this_obj & (~1));
44863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44865         PrivateRoute_free(this_obj_conv);
44866 }
44867
44868 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44869         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44870 int64_t ret_ref = 0;
44871 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44872 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44873 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44874 ret_ref = (uintptr_t)ret_var.inner;
44875 if (ret_var.is_owned) {
44876         ret_ref |= 1;
44877 }
44878         return ret_ref;
44879 }
44880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44881         LDKPrivateRoute arg_conv;
44882         arg_conv.inner = (void*)(arg & (~1));
44883         arg_conv.is_owned = false;
44884         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44885         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
44886         return ret_conv;
44887 }
44888
44889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44890         LDKPrivateRoute orig_conv;
44891         orig_conv.inner = (void*)(orig & (~1));
44892         orig_conv.is_owned = false;
44893         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44894         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44895         int64_t ret_ref = 0;
44896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44899         ret_ref = (uintptr_t)ret_var.inner;
44900         if (ret_var.is_owned) {
44901                 ret_ref |= 1;
44902         }
44903         return ret_ref;
44904 }
44905
44906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
44907         LDKPrivateRoute o_conv;
44908         o_conv.inner = (void*)(o & (~1));
44909         o_conv.is_owned = false;
44910         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44911         int64_t ret_conv = PrivateRoute_hash(&o_conv);
44912         return ret_conv;
44913 }
44914
44915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44916         LDKPrivateRoute a_conv;
44917         a_conv.inner = (void*)(a & (~1));
44918         a_conv.is_owned = false;
44919         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44920         LDKPrivateRoute b_conv;
44921         b_conv.inner = (void*)(b & (~1));
44922         b_conv.is_owned = false;
44923         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44924         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
44925         return ret_conv;
44926 }
44927
44928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
44929         LDKSignedRawInvoice this_arg_conv;
44930         this_arg_conv.inner = (void*)(this_arg & (~1));
44931         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44933         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44934         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44935         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44936         return ((int64_t)ret_conv);
44937 }
44938
44939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
44940         LDKSignedRawInvoice this_arg_conv;
44941         this_arg_conv.inner = (void*)(this_arg & (~1));
44942         this_arg_conv.is_owned = false;
44943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44944         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44945         int64_t ret_ref = 0;
44946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44949         ret_ref = (uintptr_t)ret_var.inner;
44950         if (ret_var.is_owned) {
44951                 ret_ref |= 1;
44952         }
44953         return ret_ref;
44954 }
44955
44956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44957         LDKSignedRawInvoice this_arg_conv;
44958         this_arg_conv.inner = (void*)(this_arg & (~1));
44959         this_arg_conv.is_owned = false;
44960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44961         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44962         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
44963         return ret_arr;
44964 }
44965
44966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44967         LDKSignedRawInvoice this_arg_conv;
44968         this_arg_conv.inner = (void*)(this_arg & (~1));
44969         this_arg_conv.is_owned = false;
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44971         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44972         int64_t ret_ref = 0;
44973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44976         ret_ref = (uintptr_t)ret_var.inner;
44977         if (ret_var.is_owned) {
44978                 ret_ref |= 1;
44979         }
44980         return ret_ref;
44981 }
44982
44983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44984         LDKSignedRawInvoice this_arg_conv;
44985         this_arg_conv.inner = (void*)(this_arg & (~1));
44986         this_arg_conv.is_owned = false;
44987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44988         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44989         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44990         return (int64_t)ret_conv;
44991 }
44992
44993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44994         LDKSignedRawInvoice this_arg_conv;
44995         this_arg_conv.inner = (void*)(this_arg & (~1));
44996         this_arg_conv.is_owned = false;
44997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44998         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
44999         return ret_conv;
45000 }
45001
45002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45003         LDKRawInvoice this_arg_conv;
45004         this_arg_conv.inner = (void*)(this_arg & (~1));
45005         this_arg_conv.is_owned = false;
45006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45007         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45008         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
45009         return ret_arr;
45010 }
45011
45012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45013         LDKRawInvoice this_arg_conv;
45014         this_arg_conv.inner = (void*)(this_arg & (~1));
45015         this_arg_conv.is_owned = false;
45016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45017         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
45018         int64_t ret_ref = 0;
45019         if ((uintptr_t)ret_var.inner > 4096) {
45020                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45021                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45023                 ret_ref = (uintptr_t)ret_var.inner;
45024                 if (ret_var.is_owned) {
45025                         ret_ref |= 1;
45026                 }
45027         }
45028         return ret_ref;
45029 }
45030
45031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
45032         LDKRawInvoice this_arg_conv;
45033         this_arg_conv.inner = (void*)(this_arg & (~1));
45034         this_arg_conv.is_owned = false;
45035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45036         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
45037         int64_t ret_ref = 0;
45038         if ((uintptr_t)ret_var.inner > 4096) {
45039                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45040                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45042                 ret_ref = (uintptr_t)ret_var.inner;
45043                 if (ret_var.is_owned) {
45044                         ret_ref |= 1;
45045                 }
45046         }
45047         return ret_ref;
45048 }
45049
45050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45051         LDKRawInvoice this_arg_conv;
45052         this_arg_conv.inner = (void*)(this_arg & (~1));
45053         this_arg_conv.is_owned = false;
45054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45055         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
45056         int64_t ret_ref = 0;
45057         if ((uintptr_t)ret_var.inner > 4096) {
45058                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45059                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45061                 ret_ref = (uintptr_t)ret_var.inner;
45062                 if (ret_var.is_owned) {
45063                         ret_ref |= 1;
45064                 }
45065         }
45066         return ret_ref;
45067 }
45068
45069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45070         LDKRawInvoice this_arg_conv;
45071         this_arg_conv.inner = (void*)(this_arg & (~1));
45072         this_arg_conv.is_owned = false;
45073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45074         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
45075         int64_t ret_ref = 0;
45076         if ((uintptr_t)ret_var.inner > 4096) {
45077                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45078                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45080                 ret_ref = (uintptr_t)ret_var.inner;
45081                 if (ret_var.is_owned) {
45082                         ret_ref |= 1;
45083                 }
45084         }
45085         return ret_ref;
45086 }
45087
45088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45089         LDKRawInvoice this_arg_conv;
45090         this_arg_conv.inner = (void*)(this_arg & (~1));
45091         this_arg_conv.is_owned = false;
45092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45093         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
45094         int64_t ret_ref = 0;
45095         if ((uintptr_t)ret_var.inner > 4096) {
45096                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45097                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45099                 ret_ref = (uintptr_t)ret_var.inner;
45100                 if (ret_var.is_owned) {
45101                         ret_ref |= 1;
45102                 }
45103         }
45104         return ret_ref;
45105 }
45106
45107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
45108         LDKRawInvoice this_arg_conv;
45109         this_arg_conv.inner = (void*)(this_arg & (~1));
45110         this_arg_conv.is_owned = false;
45111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45112         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
45113         int64_t ret_ref = 0;
45114         if ((uintptr_t)ret_var.inner > 4096) {
45115                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45116                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45118                 ret_ref = (uintptr_t)ret_var.inner;
45119                 if (ret_var.is_owned) {
45120                         ret_ref |= 1;
45121                 }
45122         }
45123         return ret_ref;
45124 }
45125
45126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45127         LDKRawInvoice this_arg_conv;
45128         this_arg_conv.inner = (void*)(this_arg & (~1));
45129         this_arg_conv.is_owned = false;
45130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
45133         return ret_arr;
45134 }
45135
45136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
45137         LDKRawInvoice this_arg_conv;
45138         this_arg_conv.inner = (void*)(this_arg & (~1));
45139         this_arg_conv.is_owned = false;
45140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45141         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
45142         int64_t ret_ref = 0;
45143         if ((uintptr_t)ret_var.inner > 4096) {
45144                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45145                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45147                 ret_ref = (uintptr_t)ret_var.inner;
45148                 if (ret_var.is_owned) {
45149                         ret_ref |= 1;
45150                 }
45151         }
45152         return ret_ref;
45153 }
45154
45155 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
45156         LDKRawInvoice this_arg_conv;
45157         this_arg_conv.inner = (void*)(this_arg & (~1));
45158         this_arg_conv.is_owned = false;
45159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45160         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
45161         int64_tArray ret_arr = NULL;
45162         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45163         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45164         for (size_t o = 0; o < ret_var.datalen; o++) {
45165                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45166                 int64_t ret_conv_14_ref = 0;
45167                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45168                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45169                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45170                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45171                 if (ret_conv_14_var.is_owned) {
45172                         ret_conv_14_ref |= 1;
45173                 }
45174                 ret_arr_ptr[o] = ret_conv_14_ref;
45175         }
45176         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45177         FREE(ret_var.data);
45178         return ret_arr;
45179 }
45180
45181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
45182         LDKRawInvoice this_arg_conv;
45183         this_arg_conv.inner = (void*)(this_arg & (~1));
45184         this_arg_conv.is_owned = false;
45185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45186         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45187         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
45188         int64_t ret_ref = (uintptr_t)ret_copy;
45189         return ret_ref;
45190 }
45191
45192 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
45193         LDKRawInvoice this_arg_conv;
45194         this_arg_conv.inner = (void*)(this_arg & (~1));
45195         this_arg_conv.is_owned = false;
45196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45197         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
45198         return ret_conv;
45199 }
45200
45201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
45202         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45203         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
45204         return (int64_t)ret_conv;
45205 }
45206
45207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
45208         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45209         *ret_conv = PositiveTimestamp_from_system_time(time);
45210         return (int64_t)ret_conv;
45211 }
45212
45213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
45214         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45215         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
45216         return (int64_t)ret_conv;
45217 }
45218
45219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
45220         LDKPositiveTimestamp this_arg_conv;
45221         this_arg_conv.inner = (void*)(this_arg & (~1));
45222         this_arg_conv.is_owned = false;
45223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45224         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
45225         return ret_conv;
45226 }
45227
45228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
45229         LDKPositiveTimestamp this_arg_conv;
45230         this_arg_conv.inner = (void*)(this_arg & (~1));
45231         this_arg_conv.is_owned = false;
45232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45233         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
45234         return ret_conv;
45235 }
45236
45237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45238         LDKPositiveTimestamp this_arg_conv;
45239         this_arg_conv.inner = (void*)(this_arg & (~1));
45240         this_arg_conv.is_owned = false;
45241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45242         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
45243         return ret_conv;
45244 }
45245
45246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
45247         LDKInvoice this_arg_conv;
45248         this_arg_conv.inner = (void*)(this_arg & (~1));
45249         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45251         this_arg_conv = Invoice_clone(&this_arg_conv);
45252         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
45253         int64_t ret_ref = 0;
45254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45257         ret_ref = (uintptr_t)ret_var.inner;
45258         if (ret_var.is_owned) {
45259                 ret_ref |= 1;
45260         }
45261         return ret_ref;
45262 }
45263
45264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
45265         LDKInvoice this_arg_conv;
45266         this_arg_conv.inner = (void*)(this_arg & (~1));
45267         this_arg_conv.is_owned = false;
45268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45269         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
45270         *ret_conv = Invoice_check_signature(&this_arg_conv);
45271         return (int64_t)ret_conv;
45272 }
45273
45274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
45275         LDKSignedRawInvoice signed_invoice_conv;
45276         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
45277         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
45278         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
45279         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
45280         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
45281         *ret_conv = Invoice_from_signed(signed_invoice_conv);
45282         return (int64_t)ret_conv;
45283 }
45284
45285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
45286         LDKInvoice this_arg_conv;
45287         this_arg_conv.inner = (void*)(this_arg & (~1));
45288         this_arg_conv.is_owned = false;
45289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45290         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
45291         return ret_conv;
45292 }
45293
45294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
45295         LDKInvoice this_arg_conv;
45296         this_arg_conv.inner = (void*)(this_arg & (~1));
45297         this_arg_conv.is_owned = false;
45298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45299         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
45300         return ret_conv;
45301 }
45302
45303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45304         LDKInvoice this_arg_conv;
45305         this_arg_conv.inner = (void*)(this_arg & (~1));
45306         this_arg_conv.is_owned = false;
45307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45308         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45309         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
45310         return ret_arr;
45311 }
45312
45313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45314         LDKInvoice this_arg_conv;
45315         this_arg_conv.inner = (void*)(this_arg & (~1));
45316         this_arg_conv.is_owned = false;
45317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45318         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45319         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
45320         return ret_arr;
45321 }
45322
45323 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45324         LDKInvoice this_arg_conv;
45325         this_arg_conv.inner = (void*)(this_arg & (~1));
45326         this_arg_conv.is_owned = false;
45327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45328         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
45330         return ret_arr;
45331 }
45332
45333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
45334         LDKInvoice this_arg_conv;
45335         this_arg_conv.inner = (void*)(this_arg & (~1));
45336         this_arg_conv.is_owned = false;
45337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45338         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
45339         int64_t ret_ref = 0;
45340         if ((uintptr_t)ret_var.inner > 4096) {
45341                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45342                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45344                 ret_ref = (uintptr_t)ret_var.inner;
45345                 if (ret_var.is_owned) {
45346                         ret_ref |= 1;
45347                 }
45348         }
45349         return ret_ref;
45350 }
45351
45352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45353         LDKInvoice this_arg_conv;
45354         this_arg_conv.inner = (void*)(this_arg & (~1));
45355         this_arg_conv.is_owned = false;
45356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45357         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
45359         return ret_arr;
45360 }
45361
45362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45363         LDKInvoice this_arg_conv;
45364         this_arg_conv.inner = (void*)(this_arg & (~1));
45365         this_arg_conv.is_owned = false;
45366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45367         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
45368         return ret_conv;
45369 }
45370
45371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
45372         LDKInvoice this_arg_conv;
45373         this_arg_conv.inner = (void*)(this_arg & (~1));
45374         this_arg_conv.is_owned = false;
45375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45376         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
45377         return ret_conv;
45378 }
45379
45380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
45381         LDKInvoice this_arg_conv;
45382         this_arg_conv.inner = (void*)(this_arg & (~1));
45383         this_arg_conv.is_owned = false;
45384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45385         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
45386         return ret_conv;
45387 }
45388
45389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
45390         LDKInvoice this_arg_conv;
45391         this_arg_conv.inner = (void*)(this_arg & (~1));
45392         this_arg_conv.is_owned = false;
45393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45394         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
45395         return ret_conv;
45396 }
45397
45398 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
45399         LDKInvoice this_arg_conv;
45400         this_arg_conv.inner = (void*)(this_arg & (~1));
45401         this_arg_conv.is_owned = false;
45402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45403         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
45404         int64_tArray ret_arr = NULL;
45405         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45406         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45407         for (size_t o = 0; o < ret_var.datalen; o++) {
45408                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45409                 int64_t ret_conv_14_ref = 0;
45410                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45411                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45412                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45413                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45414                 if (ret_conv_14_var.is_owned) {
45415                         ret_conv_14_ref |= 1;
45416                 }
45417                 ret_arr_ptr[o] = ret_conv_14_ref;
45418         }
45419         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45420         FREE(ret_var.data);
45421         return ret_arr;
45422 }
45423
45424 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
45425         LDKInvoice this_arg_conv;
45426         this_arg_conv.inner = (void*)(this_arg & (~1));
45427         this_arg_conv.is_owned = false;
45428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45429         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
45430         int64_tArray ret_arr = NULL;
45431         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45432         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45433         for (size_t l = 0; l < ret_var.datalen; l++) {
45434                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45435                 int64_t ret_conv_11_ref = 0;
45436                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45437                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45438                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45439                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45440                 if (ret_conv_11_var.is_owned) {
45441                         ret_conv_11_ref |= 1;
45442                 }
45443                 ret_arr_ptr[l] = ret_conv_11_ref;
45444         }
45445         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45446         FREE(ret_var.data);
45447         return ret_arr;
45448 }
45449
45450 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
45451         LDKInvoice this_arg_conv;
45452         this_arg_conv.inner = (void*)(this_arg & (~1));
45453         this_arg_conv.is_owned = false;
45454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45455         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
45456         return ret_conv;
45457 }
45458
45459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
45460         LDKInvoice this_arg_conv;
45461         this_arg_conv.inner = (void*)(this_arg & (~1));
45462         this_arg_conv.is_owned = false;
45463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45464         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45465         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45466         int64_t ret_ref = (uintptr_t)ret_copy;
45467         return ret_ref;
45468 }
45469
45470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
45471         LDKStr description_conv = java_to_owned_str(env, description);
45472         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45473         *ret_conv = Description_new(description_conv);
45474         return (int64_t)ret_conv;
45475 }
45476
45477 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45478         LDKDescription this_arg_conv;
45479         this_arg_conv.inner = (void*)(this_arg & (~1));
45480         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45482         this_arg_conv = Description_clone(&this_arg_conv);
45483         LDKStr ret_str = Description_into_inner(this_arg_conv);
45484         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45485         Str_free(ret_str);
45486         return ret_conv;
45487 }
45488
45489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
45490         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45491         int64_t ret_ref = 0;
45492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45495         ret_ref = (uintptr_t)ret_var.inner;
45496         if (ret_var.is_owned) {
45497                 ret_ref |= 1;
45498         }
45499         return ret_ref;
45500 }
45501
45502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
45503         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45504         int64_t ret_ref = 0;
45505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45508         ret_ref = (uintptr_t)ret_var.inner;
45509         if (ret_var.is_owned) {
45510                 ret_ref |= 1;
45511         }
45512         return ret_ref;
45513 }
45514
45515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
45516         LDKExpiryTime this_arg_conv;
45517         this_arg_conv.inner = (void*)(this_arg & (~1));
45518         this_arg_conv.is_owned = false;
45519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45520         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
45521         return ret_conv;
45522 }
45523
45524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
45525         LDKExpiryTime this_arg_conv;
45526         this_arg_conv.inner = (void*)(this_arg & (~1));
45527         this_arg_conv.is_owned = false;
45528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45529         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
45530         return ret_conv;
45531 }
45532
45533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
45534         LDKRouteHint hops_conv;
45535         hops_conv.inner = (void*)(hops & (~1));
45536         hops_conv.is_owned = (hops & 1) || (hops == 0);
45537         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45538         hops_conv = RouteHint_clone(&hops_conv);
45539         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45540         *ret_conv = PrivateRoute_new(hops_conv);
45541         return (int64_t)ret_conv;
45542 }
45543
45544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45545         LDKPrivateRoute this_arg_conv;
45546         this_arg_conv.inner = (void*)(this_arg & (~1));
45547         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45549         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45550         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45551         int64_t ret_ref = 0;
45552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45555         ret_ref = (uintptr_t)ret_var.inner;
45556         if (ret_var.is_owned) {
45557                 ret_ref |= 1;
45558         }
45559         return ret_ref;
45560 }
45561
45562 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45563         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
45564         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
45565         return ret_conv;
45566 }
45567
45568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
45569         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
45570         return ret_conv;
45571 }
45572
45573 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
45574         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
45575         return ret_conv;
45576 }
45577
45578 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
45579         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
45580         return ret_conv;
45581 }
45582
45583 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
45584         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
45585         return ret_conv;
45586 }
45587
45588 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
45589         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
45590         return ret_conv;
45591 }
45592
45593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45594         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
45595         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
45596         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
45597         return ret_conv;
45598 }
45599
45600 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45601         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
45602         LDKStr ret_str = CreationError_to_str(o_conv);
45603         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45604         Str_free(ret_str);
45605         return ret_conv;
45606 }
45607
45608 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45609         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
45610         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
45611         return ret_conv;
45612 }
45613
45614 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
45615         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
45616         return ret_conv;
45617 }
45618
45619 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
45620         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
45621         return ret_conv;
45622 }
45623
45624 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
45625         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
45626         return ret_conv;
45627 }
45628
45629 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
45630         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
45631         return ret_conv;
45632 }
45633
45634 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
45635         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
45636         return ret_conv;
45637 }
45638
45639 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
45640         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
45641         return ret_conv;
45642 }
45643
45644 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
45645         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
45646         return ret_conv;
45647 }
45648
45649 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
45650         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
45651         return ret_conv;
45652 }
45653
45654 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
45655         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
45656         return ret_conv;
45657 }
45658
45659 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
45660         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
45661         return ret_conv;
45662 }
45663
45664 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45665         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
45666         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
45667         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
45668         return ret_conv;
45669 }
45670
45671 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45672         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
45673         LDKStr ret_str = SemanticError_to_str(o_conv);
45674         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45675         Str_free(ret_str);
45676         return ret_conv;
45677 }
45678
45679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45680         if ((this_ptr & 1) != 0) return;
45681         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45682         CHECK_ACCESS(this_ptr_ptr);
45683         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45684         FREE((void*)this_ptr);
45685         SignOrCreationError_free(this_ptr_conv);
45686 }
45687
45688 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45689         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45690         *ret_copy = SignOrCreationError_clone(arg);
45691 int64_t ret_ref = (uintptr_t)ret_copy;
45692         return ret_ref;
45693 }
45694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45695         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
45696         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
45697         return ret_conv;
45698 }
45699
45700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45701         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
45702         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45703         *ret_copy = SignOrCreationError_clone(orig_conv);
45704         int64_t ret_ref = (uintptr_t)ret_copy;
45705         return ret_ref;
45706 }
45707
45708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
45709         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45710         *ret_copy = SignOrCreationError_sign_error();
45711         int64_t ret_ref = (uintptr_t)ret_copy;
45712         return ret_ref;
45713 }
45714
45715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
45716         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
45717         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45718         *ret_copy = SignOrCreationError_creation_error(a_conv);
45719         int64_t ret_ref = (uintptr_t)ret_copy;
45720         return ret_ref;
45721 }
45722
45723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45724         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
45725         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
45726         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
45727         return ret_conv;
45728 }
45729
45730 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45731         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
45732         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45733         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45734         Str_free(ret_str);
45735         return ret_conv;
45736 }
45737
45738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45739         LDKInvoicePayer this_obj_conv;
45740         this_obj_conv.inner = (void*)(this_obj & (~1));
45741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45743         InvoicePayer_free(this_obj_conv);
45744 }
45745
45746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45747         if ((this_ptr & 1) != 0) return;
45748         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45749         CHECK_ACCESS(this_ptr_ptr);
45750         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45751         FREE((void*)this_ptr);
45752         Payer_free(this_ptr_conv);
45753 }
45754
45755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45756         if ((this_ptr & 1) != 0) return;
45757         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45758         CHECK_ACCESS(this_ptr_ptr);
45759         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45760         FREE((void*)this_ptr);
45761         Router_free(this_ptr_conv);
45762 }
45763
45764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45765         LDKRetryAttempts this_obj_conv;
45766         this_obj_conv.inner = (void*)(this_obj & (~1));
45767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45769         RetryAttempts_free(this_obj_conv);
45770 }
45771
45772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45773         LDKRetryAttempts this_ptr_conv;
45774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45775         this_ptr_conv.is_owned = false;
45776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45777         int64_t ret_conv = RetryAttempts_get_a(&this_ptr_conv);
45778         return ret_conv;
45779 }
45780
45781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45782         LDKRetryAttempts this_ptr_conv;
45783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45784         this_ptr_conv.is_owned = false;
45785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45786         RetryAttempts_set_a(&this_ptr_conv, val);
45787 }
45788
45789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
45790         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
45791         int64_t ret_ref = 0;
45792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45795         ret_ref = (uintptr_t)ret_var.inner;
45796         if (ret_var.is_owned) {
45797                 ret_ref |= 1;
45798         }
45799         return ret_ref;
45800 }
45801
45802 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
45803         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
45804 int64_t ret_ref = 0;
45805 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45806 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45807 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45808 ret_ref = (uintptr_t)ret_var.inner;
45809 if (ret_var.is_owned) {
45810         ret_ref |= 1;
45811 }
45812         return ret_ref;
45813 }
45814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45815         LDKRetryAttempts arg_conv;
45816         arg_conv.inner = (void*)(arg & (~1));
45817         arg_conv.is_owned = false;
45818         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45819         int64_t ret_conv = RetryAttempts_clone_ptr(&arg_conv);
45820         return ret_conv;
45821 }
45822
45823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45824         LDKRetryAttempts orig_conv;
45825         orig_conv.inner = (void*)(orig & (~1));
45826         orig_conv.is_owned = false;
45827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45828         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
45829         int64_t ret_ref = 0;
45830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45833         ret_ref = (uintptr_t)ret_var.inner;
45834         if (ret_var.is_owned) {
45835                 ret_ref |= 1;
45836         }
45837         return ret_ref;
45838 }
45839
45840 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45841         LDKRetryAttempts a_conv;
45842         a_conv.inner = (void*)(a & (~1));
45843         a_conv.is_owned = false;
45844         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45845         LDKRetryAttempts b_conv;
45846         b_conv.inner = (void*)(b & (~1));
45847         b_conv.is_owned = false;
45848         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45849         jboolean ret_conv = RetryAttempts_eq(&a_conv, &b_conv);
45850         return ret_conv;
45851 }
45852
45853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
45854         LDKRetryAttempts o_conv;
45855         o_conv.inner = (void*)(o & (~1));
45856         o_conv.is_owned = false;
45857         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45858         int64_t ret_conv = RetryAttempts_hash(&o_conv);
45859         return ret_conv;
45860 }
45861
45862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45863         if ((this_ptr & 1) != 0) return;
45864         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45865         CHECK_ACCESS(this_ptr_ptr);
45866         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45867         FREE((void*)this_ptr);
45868         PaymentError_free(this_ptr_conv);
45869 }
45870
45871 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45872         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45873         *ret_copy = PaymentError_clone(arg);
45874 int64_t ret_ref = (uintptr_t)ret_copy;
45875         return ret_ref;
45876 }
45877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45878         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45879         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
45880         return ret_conv;
45881 }
45882
45883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45884         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45885         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45886         *ret_copy = PaymentError_clone(orig_conv);
45887         int64_t ret_ref = (uintptr_t)ret_copy;
45888         return ret_ref;
45889 }
45890
45891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
45892         LDKStr a_conv = java_to_owned_str(env, a);
45893         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45894         *ret_copy = PaymentError_invoice(a_conv);
45895         int64_t ret_ref = (uintptr_t)ret_copy;
45896         return ret_ref;
45897 }
45898
45899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
45900         LDKLightningError a_conv;
45901         a_conv.inner = (void*)(a & (~1));
45902         a_conv.is_owned = (a & 1) || (a == 0);
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45904         a_conv = LightningError_clone(&a_conv);
45905         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45906         *ret_copy = PaymentError_routing(a_conv);
45907         int64_t ret_ref = (uintptr_t)ret_copy;
45908         return ret_ref;
45909 }
45910
45911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
45912         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45913         CHECK_ACCESS(a_ptr);
45914         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45915         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45916         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45917         *ret_copy = PaymentError_sending(a_conv);
45918         int64_t ret_ref = (uintptr_t)ret_copy;
45919         return ret_ref;
45920 }
45921
45922 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) {
45923         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45924         CHECK_ACCESS(payer_ptr);
45925         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45926         if (payer_conv.free == LDKPayer_JCalls_free) {
45927                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45928                 LDKPayer_JCalls_cloned(&payer_conv);
45929         }
45930         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45931         CHECK_ACCESS(router_ptr);
45932         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45933         if (router_conv.free == LDKRouter_JCalls_free) {
45934                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45935                 LDKRouter_JCalls_cloned(&router_conv);
45936         }
45937         LDKMultiThreadedLockableScore scorer_conv;
45938         scorer_conv.inner = (void*)(scorer & (~1));
45939         scorer_conv.is_owned = false;
45940         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45941         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45942         CHECK_ACCESS(logger_ptr);
45943         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45944         if (logger_conv.free == LDKLogger_JCalls_free) {
45945                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45946                 LDKLogger_JCalls_cloned(&logger_conv);
45947         }
45948         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45949         CHECK_ACCESS(event_handler_ptr);
45950         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45951         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45952                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45953                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45954         }
45955         LDKRetryAttempts retry_attempts_conv;
45956         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
45957         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
45958         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
45959         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
45960         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
45961         int64_t ret_ref = 0;
45962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45965         ret_ref = (uintptr_t)ret_var.inner;
45966         if (ret_var.is_owned) {
45967                 ret_ref |= 1;
45968         }
45969         return ret_ref;
45970 }
45971
45972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
45973         LDKInvoicePayer this_arg_conv;
45974         this_arg_conv.inner = (void*)(this_arg & (~1));
45975         this_arg_conv.is_owned = false;
45976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45977         LDKInvoice invoice_conv;
45978         invoice_conv.inner = (void*)(invoice & (~1));
45979         invoice_conv.is_owned = false;
45980         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45981         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45982         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45983         return (int64_t)ret_conv;
45984 }
45985
45986 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) {
45987         LDKInvoicePayer this_arg_conv;
45988         this_arg_conv.inner = (void*)(this_arg & (~1));
45989         this_arg_conv.is_owned = false;
45990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45991         LDKInvoice invoice_conv;
45992         invoice_conv.inner = (void*)(invoice & (~1));
45993         invoice_conv.is_owned = false;
45994         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45995         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45996         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45997         return (int64_t)ret_conv;
45998 }
45999
46000 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) {
46001         LDKInvoicePayer this_arg_conv;
46002         this_arg_conv.inner = (void*)(this_arg & (~1));
46003         this_arg_conv.is_owned = false;
46004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46005         LDKPublicKey pubkey_ref;
46006         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
46007         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
46008         LDKThirtyTwoBytes payment_preimage_ref;
46009         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
46010         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
46011         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
46012         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
46013         return (int64_t)ret_conv;
46014 }
46015
46016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
46017         LDKInvoicePayer this_arg_conv;
46018         this_arg_conv.inner = (void*)(this_arg & (~1));
46019         this_arg_conv.is_owned = false;
46020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46021         unsigned char payment_hash_arr[32];
46022         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46023         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
46024         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
46025         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
46026 }
46027
46028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
46029         LDKInvoicePayer this_arg_conv;
46030         this_arg_conv.inner = (void*)(this_arg & (~1));
46031         this_arg_conv.is_owned = false;
46032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46033         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
46034         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
46035         return (int64_t)ret_ret;
46036 }
46037
46038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, jstring description, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
46039         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46040         CHECK_ACCESS(amt_msat_ptr);
46041         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46042         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46043         LDKStr description_conv = java_to_owned_str(env, description);
46044         LDKThirtyTwoBytes payment_hash_ref;
46045         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46046         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
46047         LDKThirtyTwoBytes payment_secret_ref;
46048         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
46049         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
46050         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
46051         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
46052         if (phantom_route_hints_constr.datalen > 0)
46053                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
46054         else
46055                 phantom_route_hints_constr.data = NULL;
46056         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
46057         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
46058                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
46059                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
46060                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
46061                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
46062                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
46063                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
46064                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
46065         }
46066         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
46067         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46068         CHECK_ACCESS(keys_manager_ptr);
46069         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46070         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46071                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46072                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46073         }
46074         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46075         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46076         *ret_conv = create_phantom_invoice(amt_msat_conv, description_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
46077         return (int64_t)ret_conv;
46078 }
46079
46080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int64_t description_hash, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
46081         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46082         CHECK_ACCESS(amt_msat_ptr);
46083         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46084         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46085         LDKSha256 description_hash_conv;
46086         description_hash_conv.inner = (void*)(description_hash & (~1));
46087         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46088         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46089         description_hash_conv = Sha256_clone(&description_hash_conv);
46090         LDKThirtyTwoBytes payment_hash_ref;
46091         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46092         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
46093         LDKThirtyTwoBytes payment_secret_ref;
46094         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
46095         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
46096         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
46097         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
46098         if (phantom_route_hints_constr.datalen > 0)
46099                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
46100         else
46101                 phantom_route_hints_constr.data = NULL;
46102         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
46103         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
46104                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
46105                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
46106                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
46107                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
46108                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
46109                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
46110                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
46111         }
46112         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
46113         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46114         CHECK_ACCESS(keys_manager_ptr);
46115         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46116         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46117                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46118                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46119         }
46120         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46121         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46122         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, description_hash_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
46123         return (int64_t)ret_conv;
46124 }
46125
46126 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) {
46127         LDKChannelManager channelmanager_conv;
46128         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46129         channelmanager_conv.is_owned = false;
46130         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46131         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46132         CHECK_ACCESS(keys_manager_ptr);
46133         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46134         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46135                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46136                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46137         }
46138         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46139         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46140         CHECK_ACCESS(amt_msat_ptr);
46141         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46142         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46143         LDKStr description_conv = java_to_owned_str(env, description);
46144         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46145         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
46146         return (int64_t)ret_conv;
46147 }
46148
46149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash) {
46150         LDKChannelManager channelmanager_conv;
46151         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46152         channelmanager_conv.is_owned = false;
46153         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46154         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46155         CHECK_ACCESS(keys_manager_ptr);
46156         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46157         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46159                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46160         }
46161         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46162         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46163         CHECK_ACCESS(amt_msat_ptr);
46164         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46165         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46166         LDKSha256 description_hash_conv;
46167         description_hash_conv.inner = (void*)(description_hash & (~1));
46168         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46169         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46170         description_hash_conv = Sha256_clone(&description_hash_conv);
46171         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46172         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv);
46173         return (int64_t)ret_conv;
46174 }
46175
46176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch) {
46177         LDKChannelManager channelmanager_conv;
46178         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46179         channelmanager_conv.is_owned = false;
46180         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46181         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46182         CHECK_ACCESS(keys_manager_ptr);
46183         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46184         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46185                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46186                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46187         }
46188         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46189         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46190         CHECK_ACCESS(amt_msat_ptr);
46191         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46192         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46193         LDKSha256 description_hash_conv;
46194         description_hash_conv.inner = (void*)(description_hash & (~1));
46195         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46196         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46197         description_hash_conv = Sha256_clone(&description_hash_conv);
46198         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46199         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch);
46200         return (int64_t)ret_conv;
46201 }
46202
46203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch) {
46204         LDKChannelManager channelmanager_conv;
46205         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46206         channelmanager_conv.is_owned = false;
46207         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46208         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46209         CHECK_ACCESS(keys_manager_ptr);
46210         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46211         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46212                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46213                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46214         }
46215         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46216         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46217         CHECK_ACCESS(amt_msat_ptr);
46218         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46219         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46220         LDKStr description_conv = java_to_owned_str(env, description);
46221         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46222         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch);
46223         return (int64_t)ret_conv;
46224 }
46225
46226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46227         LDKDefaultRouter this_obj_conv;
46228         this_obj_conv.inner = (void*)(this_obj & (~1));
46229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46231         DefaultRouter_free(this_obj_conv);
46232 }
46233
46234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
46235         LDKNetworkGraph network_graph_conv;
46236         network_graph_conv.inner = (void*)(network_graph & (~1));
46237         network_graph_conv.is_owned = false;
46238         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46239         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46240         CHECK_ACCESS(logger_ptr);
46241         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46242         if (logger_conv.free == LDKLogger_JCalls_free) {
46243                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46244                 LDKLogger_JCalls_cloned(&logger_conv);
46245         }
46246         LDKThirtyTwoBytes random_seed_bytes_ref;
46247         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46248         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
46249         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
46250         int64_t ret_ref = 0;
46251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46254         ret_ref = (uintptr_t)ret_var.inner;
46255         if (ret_var.is_owned) {
46256                 ret_ref |= 1;
46257         }
46258         return ret_ref;
46259 }
46260
46261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
46262         LDKDefaultRouter this_arg_conv;
46263         this_arg_conv.inner = (void*)(this_arg & (~1));
46264         this_arg_conv.is_owned = false;
46265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46266         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
46267         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
46268         return (int64_t)ret_ret;
46269 }
46270
46271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
46272         LDKChannelManager this_arg_conv;
46273         this_arg_conv.inner = (void*)(this_arg & (~1));
46274         this_arg_conv.is_owned = false;
46275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46276         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
46277         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
46278         return (int64_t)ret_ret;
46279 }
46280
46281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46282         LDKStr s_conv = java_to_owned_str(env, s);
46283         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
46284         *ret_conv = SiPrefix_from_str(s_conv);
46285         return (int64_t)ret_conv;
46286 }
46287
46288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46289         LDKStr s_conv = java_to_owned_str(env, s);
46290         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
46291         *ret_conv = Invoice_from_str(s_conv);
46292         return (int64_t)ret_conv;
46293 }
46294
46295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46296         LDKStr s_conv = java_to_owned_str(env, s);
46297         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
46298         *ret_conv = SignedRawInvoice_from_str(s_conv);
46299         return (int64_t)ret_conv;
46300 }
46301
46302 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46303         LDKParseError* o_conv = (LDKParseError*)o;
46304         LDKStr ret_str = ParseError_to_str(o_conv);
46305         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46306         Str_free(ret_str);
46307         return ret_conv;
46308 }
46309
46310 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46311         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
46312         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
46313         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46314         Str_free(ret_str);
46315         return ret_conv;
46316 }
46317
46318 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46319         LDKInvoice o_conv;
46320         o_conv.inner = (void*)(o & (~1));
46321         o_conv.is_owned = false;
46322         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46323         LDKStr ret_str = Invoice_to_str(&o_conv);
46324         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46325         Str_free(ret_str);
46326         return ret_conv;
46327 }
46328
46329 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46330         LDKSignedRawInvoice o_conv;
46331         o_conv.inner = (void*)(o & (~1));
46332         o_conv.is_owned = false;
46333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46334         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
46335         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46336         Str_free(ret_str);
46337         return ret_conv;
46338 }
46339
46340 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46341         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
46342         LDKStr ret_str = Currency_to_str(o_conv);
46343         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46344         Str_free(ret_str);
46345         return ret_conv;
46346 }
46347
46348 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46349         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
46350         LDKStr ret_str = SiPrefix_to_str(o_conv);
46351         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46352         Str_free(ret_str);
46353         return ret_conv;
46354 }
46355