]> git.bitcoin.ninja Git - ldk-java/blob - src/main/jni/bindings.c
Merge pull request #107 from TheBlueMatt/main
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
159         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
161                 (*env)->ExceptionDescribe(env);
162                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
163         }
164         switch (ord) {
165                 case 0: return LDKAccessError_UnknownChain;
166                 case 1: return LDKAccessError_UnknownTx;
167         }
168         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
169         abort(); // Unreachable, but will let the compiler know we don't return here
170 }
171 static jclass AccessError_class = NULL;
172 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
173 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
174 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
175         AccessError_class = (*env)->NewGlobalRef(env, clz);
176         CHECK(AccessError_class != NULL);
177         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
179         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
180         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
181 }
182 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
183         switch (val) {
184                 case LDKAccessError_UnknownChain:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
186                 case LDKAccessError_UnknownTx:
187                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
188                 default: abort();
189         }
190 }
191
192 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
193         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
194         if (UNLIKELY((*env)->ExceptionCheck(env))) {
195                 (*env)->ExceptionDescribe(env);
196                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
197         }
198         switch (ord) {
199                 case 0: return LDKCOption_NoneZ_Some;
200                 case 1: return LDKCOption_NoneZ_None;
201         }
202         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
203         abort(); // Unreachable, but will let the compiler know we don't return here
204 }
205 static jclass COption_NoneZ_class = NULL;
206 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
207 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
208 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
209         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
210         CHECK(COption_NoneZ_class != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
213         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
214         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
215 }
216 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
217         switch (val) {
218                 case LDKCOption_NoneZ_Some:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
220                 case LDKCOption_NoneZ_None:
221                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
222                 default: abort();
223         }
224 }
225
226 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
227         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
229                 (*env)->ExceptionDescribe(env);
230                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
231         }
232         switch (ord) {
233                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
234                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
235         }
236         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
237         abort(); // Unreachable, but will let the compiler know we don't return here
238 }
239 static jclass ChannelMonitorUpdateErr_class = NULL;
240 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
241 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
242 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
243         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
244         CHECK(ChannelMonitorUpdateErr_class != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
247         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
248         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
249 }
250 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
251         switch (val) {
252                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
254                 case LDKChannelMonitorUpdateErr_PermanentFailure:
255                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
256                 default: abort();
257         }
258 }
259
260 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
261         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
263                 (*env)->ExceptionDescribe(env);
264                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
265         }
266         switch (ord) {
267                 case 0: return LDKConfirmationTarget_Background;
268                 case 1: return LDKConfirmationTarget_Normal;
269                 case 2: return LDKConfirmationTarget_HighPriority;
270         }
271         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
272         abort(); // Unreachable, but will let the compiler know we don't return here
273 }
274 static jclass ConfirmationTarget_class = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
276 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
277 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
279         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(ConfirmationTarget_class != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
285         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
286         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
287 }
288 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
289         switch (val) {
290                 case LDKConfirmationTarget_Background:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
292                 case LDKConfirmationTarget_Normal:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
294                 case LDKConfirmationTarget_HighPriority:
295                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
296                 default: abort();
297         }
298 }
299
300 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
301         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
303                 (*env)->ExceptionDescribe(env);
304                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
305         }
306         switch (ord) {
307                 case 0: return LDKCreationError_DescriptionTooLong;
308                 case 1: return LDKCreationError_RouteTooLong;
309                 case 2: return LDKCreationError_TimestampOutOfBounds;
310                 case 3: return LDKCreationError_InvalidAmount;
311                 case 4: return LDKCreationError_MissingRouteHints;
312         }
313         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
314         abort(); // Unreachable, but will let the compiler know we don't return here
315 }
316 static jclass CreationError_class = NULL;
317 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
318 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
319 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
320 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
321 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
322 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
323         CreationError_class = (*env)->NewGlobalRef(env, clz);
324         CHECK(CreationError_class != NULL);
325         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
327         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
329         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
335 }
336 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
337         switch (val) {
338                 case LDKCreationError_DescriptionTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
340                 case LDKCreationError_RouteTooLong:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
342                 case LDKCreationError_TimestampOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 case LDKCreationError_MissingRouteHints:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
348                 default: abort();
349         }
350 }
351
352 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
353         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
355                 (*env)->ExceptionDescribe(env);
356                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
357         }
358         switch (ord) {
359                 case 0: return LDKCurrency_Bitcoin;
360                 case 1: return LDKCurrency_BitcoinTestnet;
361                 case 2: return LDKCurrency_Regtest;
362                 case 3: return LDKCurrency_Simnet;
363                 case 4: return LDKCurrency_Signet;
364         }
365         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
366         abort(); // Unreachable, but will let the compiler know we don't return here
367 }
368 static jclass Currency_class = NULL;
369 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
370 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
371 static jfieldID Currency_LDKCurrency_Regtest = NULL;
372 static jfieldID Currency_LDKCurrency_Simnet = NULL;
373 static jfieldID Currency_LDKCurrency_Signet = NULL;
374 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
375         Currency_class = (*env)->NewGlobalRef(env, clz);
376         CHECK(Currency_class != NULL);
377         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
379         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
381         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Regtest != NULL);
383         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Simnet != NULL);
385         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
386         CHECK(Currency_LDKCurrency_Signet != NULL);
387 }
388 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
389         switch (val) {
390                 case LDKCurrency_Bitcoin:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
392                 case LDKCurrency_BitcoinTestnet:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
394                 case LDKCurrency_Regtest:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
396                 case LDKCurrency_Simnet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
398                 case LDKCurrency_Signet:
399                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
400                 default: abort();
401         }
402 }
403
404 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKIOError_NotFound;
412                 case 1: return LDKIOError_PermissionDenied;
413                 case 2: return LDKIOError_ConnectionRefused;
414                 case 3: return LDKIOError_ConnectionReset;
415                 case 4: return LDKIOError_ConnectionAborted;
416                 case 5: return LDKIOError_NotConnected;
417                 case 6: return LDKIOError_AddrInUse;
418                 case 7: return LDKIOError_AddrNotAvailable;
419                 case 8: return LDKIOError_BrokenPipe;
420                 case 9: return LDKIOError_AlreadyExists;
421                 case 10: return LDKIOError_WouldBlock;
422                 case 11: return LDKIOError_InvalidInput;
423                 case 12: return LDKIOError_InvalidData;
424                 case 13: return LDKIOError_TimedOut;
425                 case 14: return LDKIOError_WriteZero;
426                 case 15: return LDKIOError_Interrupted;
427                 case 16: return LDKIOError_Other;
428                 case 17: return LDKIOError_UnexpectedEof;
429         }
430         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
431         abort(); // Unreachable, but will let the compiler know we don't return here
432 }
433 static jclass IOError_class = NULL;
434 static jfieldID IOError_LDKIOError_NotFound = NULL;
435 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
437 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
438 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
439 static jfieldID IOError_LDKIOError_NotConnected = NULL;
440 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
441 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
442 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
443 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
444 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
445 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
446 static jfieldID IOError_LDKIOError_InvalidData = NULL;
447 static jfieldID IOError_LDKIOError_TimedOut = NULL;
448 static jfieldID IOError_LDKIOError_WriteZero = NULL;
449 static jfieldID IOError_LDKIOError_Interrupted = NULL;
450 static jfieldID IOError_LDKIOError_Other = NULL;
451 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
452 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
453         IOError_class = (*env)->NewGlobalRef(env, clz);
454         CHECK(IOError_class != NULL);
455         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_NotFound != NULL);
457         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
459         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
461         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
463         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
465         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_NotConnected != NULL);
467         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrInUse != NULL);
469         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
471         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
473         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
475         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_WouldBlock != NULL);
477         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidInput != NULL);
479         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_InvalidData != NULL);
481         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_TimedOut != NULL);
483         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_WriteZero != NULL);
485         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Interrupted != NULL);
487         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_Other != NULL);
489         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
490         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
491 }
492 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
493         switch (val) {
494                 case LDKIOError_NotFound:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
496                 case LDKIOError_PermissionDenied:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
498                 case LDKIOError_ConnectionRefused:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
500                 case LDKIOError_ConnectionReset:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
502                 case LDKIOError_ConnectionAborted:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
504                 case LDKIOError_NotConnected:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
506                 case LDKIOError_AddrInUse:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
508                 case LDKIOError_AddrNotAvailable:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
510                 case LDKIOError_BrokenPipe:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
512                 case LDKIOError_AlreadyExists:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
514                 case LDKIOError_WouldBlock:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
516                 case LDKIOError_InvalidInput:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
518                 case LDKIOError_InvalidData:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
520                 case LDKIOError_TimedOut:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
522                 case LDKIOError_WriteZero:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
524                 case LDKIOError_Interrupted:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
526                 case LDKIOError_Other:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
528                 case LDKIOError_UnexpectedEof:
529                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
530                 default: abort();
531         }
532 }
533
534 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
535         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
537                 (*env)->ExceptionDescribe(env);
538                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
539         }
540         switch (ord) {
541                 case 0: return LDKLevel_Gossip;
542                 case 1: return LDKLevel_Trace;
543                 case 2: return LDKLevel_Debug;
544                 case 3: return LDKLevel_Info;
545                 case 4: return LDKLevel_Warn;
546                 case 5: return LDKLevel_Error;
547         }
548         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
549         abort(); // Unreachable, but will let the compiler know we don't return here
550 }
551 static jclass Level_class = NULL;
552 static jfieldID Level_LDKLevel_Gossip = NULL;
553 static jfieldID Level_LDKLevel_Trace = NULL;
554 static jfieldID Level_LDKLevel_Debug = NULL;
555 static jfieldID Level_LDKLevel_Info = NULL;
556 static jfieldID Level_LDKLevel_Warn = NULL;
557 static jfieldID Level_LDKLevel_Error = NULL;
558 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
559         Level_class = (*env)->NewGlobalRef(env, clz);
560         CHECK(Level_class != NULL);
561         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Gossip != NULL);
563         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Trace != NULL);
565         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Debug != NULL);
567         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Info != NULL);
569         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Warn != NULL);
571         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
572         CHECK(Level_LDKLevel_Error != NULL);
573 }
574 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
575         switch (val) {
576                 case LDKLevel_Gossip:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
578                 case LDKLevel_Trace:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
580                 case LDKLevel_Debug:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
582                 case LDKLevel_Info:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
584                 case LDKLevel_Warn:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
586                 case LDKLevel_Error:
587                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
588                 default: abort();
589         }
590 }
591
592 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
593         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
595                 (*env)->ExceptionDescribe(env);
596                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
597         }
598         switch (ord) {
599                 case 0: return LDKNetwork_Bitcoin;
600                 case 1: return LDKNetwork_Testnet;
601                 case 2: return LDKNetwork_Regtest;
602                 case 3: return LDKNetwork_Signet;
603         }
604         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
605         abort(); // Unreachable, but will let the compiler know we don't return here
606 }
607 static jclass Network_class = NULL;
608 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
609 static jfieldID Network_LDKNetwork_Testnet = NULL;
610 static jfieldID Network_LDKNetwork_Regtest = NULL;
611 static jfieldID Network_LDKNetwork_Signet = NULL;
612 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
613         Network_class = (*env)->NewGlobalRef(env, clz);
614         CHECK(Network_class != NULL);
615         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Bitcoin != NULL);
617         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Testnet != NULL);
619         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Regtest != NULL);
621         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
622         CHECK(Network_LDKNetwork_Signet != NULL);
623 }
624 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
625         switch (val) {
626                 case LDKNetwork_Bitcoin:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
628                 case LDKNetwork_Testnet:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
630                 case LDKNetwork_Regtest:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
632                 case LDKNetwork_Signet:
633                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
634                 default: abort();
635         }
636 }
637
638 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
639         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
641                 (*env)->ExceptionDescribe(env);
642                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKRecipient_Node;
646                 case 1: return LDKRecipient_PhantomNode;
647         }
648         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
649         abort(); // Unreachable, but will let the compiler know we don't return here
650 }
651 static jclass Recipient_class = NULL;
652 static jfieldID Recipient_LDKRecipient_Node = NULL;
653 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
654 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
655         Recipient_class = (*env)->NewGlobalRef(env, clz);
656         CHECK(Recipient_class != NULL);
657         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_Node != NULL);
659         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
660         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
661 }
662 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
663         switch (val) {
664                 case LDKRecipient_Node:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
666                 case LDKRecipient_PhantomNode:
667                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
668                 default: abort();
669         }
670 }
671
672 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
673         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
675                 (*env)->ExceptionDescribe(env);
676                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
677         }
678         switch (ord) {
679                 case 0: return LDKSecp256k1Error_IncorrectSignature;
680                 case 1: return LDKSecp256k1Error_InvalidMessage;
681                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
682                 case 3: return LDKSecp256k1Error_InvalidSignature;
683                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
684                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
685                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
686                 case 7: return LDKSecp256k1Error_InvalidTweak;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
689                 case 10: return LDKSecp256k1Error_InvalidParityValue;
690         }
691         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
692         abort(); // Unreachable, but will let the compiler know we don't return here
693 }
694 static jclass Secp256k1Error_class = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
702 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
703 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
704 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
705 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
706 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
707         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
708         CHECK(Secp256k1Error_class != NULL);
709         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
719         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
721         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
723         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
724         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
725         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
726         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
727         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
728         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
729         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
730         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
731 }
732 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
733         switch (val) {
734                 case LDKSecp256k1Error_IncorrectSignature:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
736                 case LDKSecp256k1Error_InvalidMessage:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
738                 case LDKSecp256k1Error_InvalidPublicKey:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
740                 case LDKSecp256k1Error_InvalidSignature:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
742                 case LDKSecp256k1Error_InvalidSecretKey:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
744                 case LDKSecp256k1Error_InvalidSharedSecret:
745                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
746                 case LDKSecp256k1Error_InvalidRecoveryId:
747                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
748                 case LDKSecp256k1Error_InvalidTweak:
749                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
750                 case LDKSecp256k1Error_NotEnoughMemory:
751                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
752                 case LDKSecp256k1Error_InvalidPublicKeySum:
753                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
754                 case LDKSecp256k1Error_InvalidParityValue:
755                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
756                 default: abort();
757         }
758 }
759
760 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
761         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
762         if (UNLIKELY((*env)->ExceptionCheck(env))) {
763                 (*env)->ExceptionDescribe(env);
764                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
765         }
766         switch (ord) {
767                 case 0: return LDKSemanticError_NoPaymentHash;
768                 case 1: return LDKSemanticError_MultiplePaymentHashes;
769                 case 2: return LDKSemanticError_NoDescription;
770                 case 3: return LDKSemanticError_MultipleDescriptions;
771                 case 4: return LDKSemanticError_NoPaymentSecret;
772                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
773                 case 6: return LDKSemanticError_InvalidFeatures;
774                 case 7: return LDKSemanticError_InvalidRecoveryId;
775                 case 8: return LDKSemanticError_InvalidSignature;
776                 case 9: return LDKSemanticError_ImpreciseAmount;
777         }
778         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
779         abort(); // Unreachable, but will let the compiler know we don't return here
780 }
781 static jclass SemanticError_class = NULL;
782 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
783 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
784 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
785 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
786 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
787 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
788 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
789 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
790 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
791 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
792 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
793         SemanticError_class = (*env)->NewGlobalRef(env, clz);
794         CHECK(SemanticError_class != NULL);
795         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
797         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
799         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
801         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
803         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
804         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
805         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
806         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
807         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
808         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
809         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
810         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
811         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
812         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
813         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
814         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
815 }
816 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
817         switch (val) {
818                 case LDKSemanticError_NoPaymentHash:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
820                 case LDKSemanticError_MultiplePaymentHashes:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
822                 case LDKSemanticError_NoDescription:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
824                 case LDKSemanticError_MultipleDescriptions:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
826                 case LDKSemanticError_NoPaymentSecret:
827                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
828                 case LDKSemanticError_MultiplePaymentSecrets:
829                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
830                 case LDKSemanticError_InvalidFeatures:
831                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
832                 case LDKSemanticError_InvalidRecoveryId:
833                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
834                 case LDKSemanticError_InvalidSignature:
835                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
836                 case LDKSemanticError_ImpreciseAmount:
837                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
838                 default: abort();
839         }
840 }
841
842 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
843         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
845                 (*env)->ExceptionDescribe(env);
846                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
847         }
848         switch (ord) {
849                 case 0: return LDKSiPrefix_Milli;
850                 case 1: return LDKSiPrefix_Micro;
851                 case 2: return LDKSiPrefix_Nano;
852                 case 3: return LDKSiPrefix_Pico;
853         }
854         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
855         abort(); // Unreachable, but will let the compiler know we don't return here
856 }
857 static jclass SiPrefix_class = NULL;
858 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
859 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
860 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
861 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
862 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
863         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
864         CHECK(SiPrefix_class != NULL);
865         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
866         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
867         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
868         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
869         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
870         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
871         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
872         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
873 }
874 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
875         switch (val) {
876                 case LDKSiPrefix_Milli:
877                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
878                 case LDKSiPrefix_Micro:
879                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
880                 case LDKSiPrefix_Nano:
881                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
882                 case LDKSiPrefix_Pico:
883                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
884                 default: abort();
885         }
886 }
887
888 static jclass LDKBech32Error_MissingSeparator_class = NULL;
889 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
890 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
891 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
892 static jclass LDKBech32Error_InvalidLength_class = NULL;
893 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
894 static jclass LDKBech32Error_InvalidChar_class = NULL;
895 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
896 static jclass LDKBech32Error_InvalidData_class = NULL;
897 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
898 static jclass LDKBech32Error_InvalidPadding_class = NULL;
899 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
900 static jclass LDKBech32Error_MixedCase_class = NULL;
901 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
903         LDKBech32Error_MissingSeparator_class =
904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
905         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
906         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
907         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
908         LDKBech32Error_InvalidChecksum_class =
909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
910         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
911         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
912         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
913         LDKBech32Error_InvalidLength_class =
914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
915         CHECK(LDKBech32Error_InvalidLength_class != NULL);
916         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
917         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
918         LDKBech32Error_InvalidChar_class =
919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
920         CHECK(LDKBech32Error_InvalidChar_class != NULL);
921         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
922         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
923         LDKBech32Error_InvalidData_class =
924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
925         CHECK(LDKBech32Error_InvalidData_class != NULL);
926         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
927         CHECK(LDKBech32Error_InvalidData_meth != NULL);
928         LDKBech32Error_InvalidPadding_class =
929                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
930         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
931         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
932         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
933         LDKBech32Error_MixedCase_class =
934                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
935         CHECK(LDKBech32Error_MixedCase_class != NULL);
936         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
937         CHECK(LDKBech32Error_MixedCase_meth != NULL);
938 }
939 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
940         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
941         switch(obj->tag) {
942                 case LDKBech32Error_MissingSeparator: {
943                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
944                 }
945                 case LDKBech32Error_InvalidChecksum: {
946                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
947                 }
948                 case LDKBech32Error_InvalidLength: {
949                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
950                 }
951                 case LDKBech32Error_InvalidChar: {
952                         int32_t invalid_char_conv = obj->invalid_char;
953                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
954                 }
955                 case LDKBech32Error_InvalidData: {
956                         int8_t invalid_data_conv = obj->invalid_data;
957                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
958                 }
959                 case LDKBech32Error_InvalidPadding: {
960                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
961                 }
962                 case LDKBech32Error_MixedCase: {
963                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
964                 }
965                 default: abort();
966         }
967 }
968 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
969         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
970         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
971         return ret;
972 }
973 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
974         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
975         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
976         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
977         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
978         CVec_u8Z_free(ret_var);
979         return ret_arr;
980 }
981
982 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
983         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
984         int64_t ret_conv = TxOut_get_value(thing_conv);
985         return ret_conv;
986 }
987
988 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
989 CHECK(owner->result_ok);
990         return *owner->contents.result;
991 }
992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
993         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
994         CResult_NoneNoneZ_get_ok(owner_conv);
995 }
996
997 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
998 CHECK(!owner->result_ok);
999         return *owner->contents.err;
1000 }
1001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1002         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1003         CResult_NoneNoneZ_get_err(owner_conv);
1004 }
1005
1006 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1007 CHECK(owner->result_ok);
1008         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
1009 }
1010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1011         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1012         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1013         int64_t ret_ref = 0;
1014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1017         ret_ref = (uintptr_t)ret_var.inner;
1018         if (ret_var.is_owned) {
1019                 ret_ref |= 1;
1020         }
1021         return ret_ref;
1022 }
1023
1024 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1025 CHECK(!owner->result_ok);
1026         return DecodeError_clone(&*owner->contents.err);
1027 }
1028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1029         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1030         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1031         int64_t ret_ref = 0;
1032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1035         ret_ref = (uintptr_t)ret_var.inner;
1036         if (ret_var.is_owned) {
1037                 ret_ref |= 1;
1038         }
1039         return ret_ref;
1040 }
1041
1042 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1043 CHECK(owner->result_ok);
1044         return *owner->contents.result;
1045 }
1046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1047         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1050         return ret_arr;
1051 }
1052
1053 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1054 CHECK(!owner->result_ok);
1055         return *owner->contents.err;
1056 }
1057 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1058         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1059         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1060         return ret_conv;
1061 }
1062
1063 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1064 CHECK(owner->result_ok);
1065         return *owner->contents.result;
1066 }
1067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1068         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1069         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1071         return ret_arr;
1072 }
1073
1074 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1075 CHECK(!owner->result_ok);
1076         return *owner->contents.err;
1077 }
1078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1079         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1080         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1081         return ret_conv;
1082 }
1083
1084 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1085 CHECK(owner->result_ok);
1086         return TxCreationKeys_clone(&*owner->contents.result);
1087 }
1088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1089         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1090         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1091         int64_t ret_ref = 0;
1092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1095         ret_ref = (uintptr_t)ret_var.inner;
1096         if (ret_var.is_owned) {
1097                 ret_ref |= 1;
1098         }
1099         return ret_ref;
1100 }
1101
1102 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1103 CHECK(!owner->result_ok);
1104         return DecodeError_clone(&*owner->contents.err);
1105 }
1106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1107         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1108         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1109         int64_t ret_ref = 0;
1110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1113         ret_ref = (uintptr_t)ret_var.inner;
1114         if (ret_var.is_owned) {
1115                 ret_ref |= 1;
1116         }
1117         return ret_ref;
1118 }
1119
1120 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1121 CHECK(owner->result_ok);
1122         return ChannelPublicKeys_clone(&*owner->contents.result);
1123 }
1124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1126         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1127         int64_t ret_ref = 0;
1128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1131         ret_ref = (uintptr_t)ret_var.inner;
1132         if (ret_var.is_owned) {
1133                 ret_ref |= 1;
1134         }
1135         return ret_ref;
1136 }
1137
1138 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1139 CHECK(!owner->result_ok);
1140         return DecodeError_clone(&*owner->contents.err);
1141 }
1142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1143         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1144         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1145         int64_t ret_ref = 0;
1146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1149         ret_ref = (uintptr_t)ret_var.inner;
1150         if (ret_var.is_owned) {
1151                 ret_ref |= 1;
1152         }
1153         return ret_ref;
1154 }
1155
1156 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1157 CHECK(owner->result_ok);
1158         return TxCreationKeys_clone(&*owner->contents.result);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1162         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1163         int64_t ret_ref = 0;
1164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1167         ret_ref = (uintptr_t)ret_var.inner;
1168         if (ret_var.is_owned) {
1169                 ret_ref |= 1;
1170         }
1171         return ret_ref;
1172 }
1173
1174 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1175 CHECK(!owner->result_ok);
1176         return *owner->contents.err;
1177 }
1178 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1180         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1181         return ret_conv;
1182 }
1183
1184 static jclass LDKCOption_u32Z_Some_class = NULL;
1185 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1186 static jclass LDKCOption_u32Z_None_class = NULL;
1187 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1189         LDKCOption_u32Z_Some_class =
1190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1191         CHECK(LDKCOption_u32Z_Some_class != NULL);
1192         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1193         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1194         LDKCOption_u32Z_None_class =
1195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1196         CHECK(LDKCOption_u32Z_None_class != NULL);
1197         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1198         CHECK(LDKCOption_u32Z_None_meth != NULL);
1199 }
1200 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1201         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1202         switch(obj->tag) {
1203                 case LDKCOption_u32Z_Some: {
1204                         int32_t some_conv = obj->some;
1205                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1206                 }
1207                 case LDKCOption_u32Z_None: {
1208                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1209                 }
1210                 default: abort();
1211         }
1212 }
1213 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1214 CHECK(owner->result_ok);
1215         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1216 }
1217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1218         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1219         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1220         int64_t ret_ref = 0;
1221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1224         ret_ref = (uintptr_t)ret_var.inner;
1225         if (ret_var.is_owned) {
1226                 ret_ref |= 1;
1227         }
1228         return ret_ref;
1229 }
1230
1231 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1232 CHECK(!owner->result_ok);
1233         return DecodeError_clone(&*owner->contents.err);
1234 }
1235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1236         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1237         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1238         int64_t ret_ref = 0;
1239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1242         ret_ref = (uintptr_t)ret_var.inner;
1243         if (ret_var.is_owned) {
1244                 ret_ref |= 1;
1245         }
1246         return ret_ref;
1247 }
1248
1249 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1250 CHECK(owner->result_ok);
1251         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1252 }
1253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1254         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1255         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1256         int64_t ret_ref = 0;
1257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1260         ret_ref = (uintptr_t)ret_var.inner;
1261         if (ret_var.is_owned) {
1262                 ret_ref |= 1;
1263         }
1264         return ret_ref;
1265 }
1266
1267 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1268 CHECK(!owner->result_ok);
1269         return DecodeError_clone(&*owner->contents.err);
1270 }
1271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1272         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1273         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1274         int64_t ret_ref = 0;
1275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1278         ret_ref = (uintptr_t)ret_var.inner;
1279         if (ret_var.is_owned) {
1280                 ret_ref |= 1;
1281         }
1282         return ret_ref;
1283 }
1284
1285 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1286 CHECK(owner->result_ok);
1287         return ChannelTransactionParameters_clone(&*owner->contents.result);
1288 }
1289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1290         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1291         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1292         int64_t ret_ref = 0;
1293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1296         ret_ref = (uintptr_t)ret_var.inner;
1297         if (ret_var.is_owned) {
1298                 ret_ref |= 1;
1299         }
1300         return ret_ref;
1301 }
1302
1303 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1304 CHECK(!owner->result_ok);
1305         return DecodeError_clone(&*owner->contents.err);
1306 }
1307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1308         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1309         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1310         int64_t ret_ref = 0;
1311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1314         ret_ref = (uintptr_t)ret_var.inner;
1315         if (ret_var.is_owned) {
1316                 ret_ref |= 1;
1317         }
1318         return ret_ref;
1319 }
1320
1321 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1322 CHECK(owner->result_ok);
1323         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1326         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1327         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1328         int64_t ret_ref = 0;
1329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1332         ret_ref = (uintptr_t)ret_var.inner;
1333         if (ret_var.is_owned) {
1334                 ret_ref |= 1;
1335         }
1336         return ret_ref;
1337 }
1338
1339 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1340 CHECK(!owner->result_ok);
1341         return DecodeError_clone(&*owner->contents.err);
1342 }
1343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1344         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1345         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1346         int64_t ret_ref = 0;
1347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1350         ret_ref = (uintptr_t)ret_var.inner;
1351         if (ret_var.is_owned) {
1352                 ret_ref |= 1;
1353         }
1354         return ret_ref;
1355 }
1356
1357 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1358 CHECK(owner->result_ok);
1359         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1360 }
1361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1362         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1363         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1364         int64_t ret_ref = 0;
1365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1368         ret_ref = (uintptr_t)ret_var.inner;
1369         if (ret_var.is_owned) {
1370                 ret_ref |= 1;
1371         }
1372         return ret_ref;
1373 }
1374
1375 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1376 CHECK(!owner->result_ok);
1377         return DecodeError_clone(&*owner->contents.err);
1378 }
1379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1380         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1381         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1382         int64_t ret_ref = 0;
1383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1386         ret_ref = (uintptr_t)ret_var.inner;
1387         if (ret_var.is_owned) {
1388                 ret_ref |= 1;
1389         }
1390         return ret_ref;
1391 }
1392
1393 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1394 CHECK(owner->result_ok);
1395         return &*owner->contents.result;
1396 }
1397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1398         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1399         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1400         int64_t ret_ref = 0;
1401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1404         ret_ref = (uintptr_t)ret_var.inner & ~1;
1405         return ret_ref;
1406 }
1407
1408 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1409 CHECK(!owner->result_ok);
1410         return *owner->contents.err;
1411 }
1412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1413         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1414         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1415 }
1416
1417 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1418 CHECK(owner->result_ok);
1419         return CommitmentTransaction_clone(&*owner->contents.result);
1420 }
1421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1422         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1423         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1424         int64_t ret_ref = 0;
1425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1428         ret_ref = (uintptr_t)ret_var.inner;
1429         if (ret_var.is_owned) {
1430                 ret_ref |= 1;
1431         }
1432         return ret_ref;
1433 }
1434
1435 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1436 CHECK(!owner->result_ok);
1437         return DecodeError_clone(&*owner->contents.err);
1438 }
1439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1440         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1441         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1442         int64_t ret_ref = 0;
1443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1446         ret_ref = (uintptr_t)ret_var.inner;
1447         if (ret_var.is_owned) {
1448                 ret_ref |= 1;
1449         }
1450         return ret_ref;
1451 }
1452
1453 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1454 CHECK(owner->result_ok);
1455         return &*owner->contents.result;
1456 }
1457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1458         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1459         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1460         int64_t ret_ref = 0;
1461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1464         ret_ref = (uintptr_t)ret_var.inner & ~1;
1465         return ret_ref;
1466 }
1467
1468 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1469 CHECK(!owner->result_ok);
1470         return *owner->contents.err;
1471 }
1472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1473         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1474         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1475 }
1476
1477 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1478 CHECK(owner->result_ok);
1479         return *owner->contents.result;
1480 }
1481 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1482         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1483         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1484         jobjectArray ret_arr = NULL;
1485         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1486         ;
1487         for (size_t i = 0; i < ret_var.datalen; i++) {
1488                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1489                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1490                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1491         }
1492         
1493         return ret_arr;
1494 }
1495
1496 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1497 CHECK(!owner->result_ok);
1498         return *owner->contents.err;
1499 }
1500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1501         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1502         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1503 }
1504
1505 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1506 CHECK(owner->result_ok);
1507         return ShutdownScript_clone(&*owner->contents.result);
1508 }
1509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1510         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1511         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1512         int64_t ret_ref = 0;
1513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1516         ret_ref = (uintptr_t)ret_var.inner;
1517         if (ret_var.is_owned) {
1518                 ret_ref |= 1;
1519         }
1520         return ret_ref;
1521 }
1522
1523 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1524 CHECK(!owner->result_ok);
1525         return DecodeError_clone(&*owner->contents.err);
1526 }
1527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1528         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1529         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1530         int64_t ret_ref = 0;
1531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1534         ret_ref = (uintptr_t)ret_var.inner;
1535         if (ret_var.is_owned) {
1536                 ret_ref |= 1;
1537         }
1538         return ret_ref;
1539 }
1540
1541 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1542 CHECK(owner->result_ok);
1543         return ShutdownScript_clone(&*owner->contents.result);
1544 }
1545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1546         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1547         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1548         int64_t ret_ref = 0;
1549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1552         ret_ref = (uintptr_t)ret_var.inner;
1553         if (ret_var.is_owned) {
1554                 ret_ref |= 1;
1555         }
1556         return ret_ref;
1557 }
1558
1559 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1560 CHECK(!owner->result_ok);
1561         return InvalidShutdownScript_clone(&*owner->contents.err);
1562 }
1563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1564         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1565         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1566         int64_t ret_ref = 0;
1567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1570         ret_ref = (uintptr_t)ret_var.inner;
1571         if (ret_var.is_owned) {
1572                 ret_ref |= 1;
1573         }
1574         return ret_ref;
1575 }
1576
1577 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1578 CHECK(owner->result_ok);
1579         return *owner->contents.result;
1580 }
1581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1582         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1583         CResult_NoneErrorZ_get_ok(owner_conv);
1584 }
1585
1586 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1587 CHECK(!owner->result_ok);
1588         return *owner->contents.err;
1589 }
1590 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1591         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1592         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1593         return ret_conv;
1594 }
1595
1596 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1597 CHECK(owner->result_ok);
1598         return RouteHop_clone(&*owner->contents.result);
1599 }
1600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1601         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1602         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1603         int64_t ret_ref = 0;
1604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1607         ret_ref = (uintptr_t)ret_var.inner;
1608         if (ret_var.is_owned) {
1609                 ret_ref |= 1;
1610         }
1611         return ret_ref;
1612 }
1613
1614 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1615 CHECK(!owner->result_ok);
1616         return DecodeError_clone(&*owner->contents.err);
1617 }
1618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1619         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1620         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1621         int64_t ret_ref = 0;
1622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1625         ret_ref = (uintptr_t)ret_var.inner;
1626         if (ret_var.is_owned) {
1627                 ret_ref |= 1;
1628         }
1629         return ret_ref;
1630 }
1631
1632 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1633         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1634         for (size_t i = 0; i < ret.datalen; i++) {
1635                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1636         }
1637         return ret;
1638 }
1639 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1640         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1641         for (size_t i = 0; i < ret.datalen; i++) {
1642                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1643         }
1644         return ret;
1645 }
1646 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1647 CHECK(owner->result_ok);
1648         return Route_clone(&*owner->contents.result);
1649 }
1650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1651         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1652         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1653         int64_t ret_ref = 0;
1654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1657         ret_ref = (uintptr_t)ret_var.inner;
1658         if (ret_var.is_owned) {
1659                 ret_ref |= 1;
1660         }
1661         return ret_ref;
1662 }
1663
1664 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1665 CHECK(!owner->result_ok);
1666         return DecodeError_clone(&*owner->contents.err);
1667 }
1668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1669         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1670         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1671         int64_t ret_ref = 0;
1672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1675         ret_ref = (uintptr_t)ret_var.inner;
1676         if (ret_var.is_owned) {
1677                 ret_ref |= 1;
1678         }
1679         return ret_ref;
1680 }
1681
1682 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1683 CHECK(owner->result_ok);
1684         return RouteParameters_clone(&*owner->contents.result);
1685 }
1686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1687         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1688         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1689         int64_t ret_ref = 0;
1690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1693         ret_ref = (uintptr_t)ret_var.inner;
1694         if (ret_var.is_owned) {
1695                 ret_ref |= 1;
1696         }
1697         return ret_ref;
1698 }
1699
1700 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1701 CHECK(!owner->result_ok);
1702         return DecodeError_clone(&*owner->contents.err);
1703 }
1704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1705         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1706         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1707         int64_t ret_ref = 0;
1708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1711         ret_ref = (uintptr_t)ret_var.inner;
1712         if (ret_var.is_owned) {
1713                 ret_ref |= 1;
1714         }
1715         return ret_ref;
1716 }
1717
1718 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1719         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1720         for (size_t i = 0; i < ret.datalen; i++) {
1721                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1722         }
1723         return ret;
1724 }
1725 static jclass LDKCOption_u64Z_Some_class = NULL;
1726 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1727 static jclass LDKCOption_u64Z_None_class = NULL;
1728 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1730         LDKCOption_u64Z_Some_class =
1731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1732         CHECK(LDKCOption_u64Z_Some_class != NULL);
1733         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1734         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1735         LDKCOption_u64Z_None_class =
1736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1737         CHECK(LDKCOption_u64Z_None_class != NULL);
1738         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1739         CHECK(LDKCOption_u64Z_None_meth != NULL);
1740 }
1741 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1742         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1743         switch(obj->tag) {
1744                 case LDKCOption_u64Z_Some: {
1745                         int64_t some_conv = obj->some;
1746                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1747                 }
1748                 case LDKCOption_u64Z_None: {
1749                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1750                 }
1751                 default: abort();
1752         }
1753 }
1754 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1755 CHECK(owner->result_ok);
1756         return PaymentParameters_clone(&*owner->contents.result);
1757 }
1758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1759         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1760         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1761         int64_t ret_ref = 0;
1762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1765         ret_ref = (uintptr_t)ret_var.inner;
1766         if (ret_var.is_owned) {
1767                 ret_ref |= 1;
1768         }
1769         return ret_ref;
1770 }
1771
1772 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1773 CHECK(!owner->result_ok);
1774         return DecodeError_clone(&*owner->contents.err);
1775 }
1776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1777         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1778         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1779         int64_t ret_ref = 0;
1780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1783         ret_ref = (uintptr_t)ret_var.inner;
1784         if (ret_var.is_owned) {
1785                 ret_ref |= 1;
1786         }
1787         return ret_ref;
1788 }
1789
1790 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1791         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1792         for (size_t i = 0; i < ret.datalen; i++) {
1793                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1794         }
1795         return ret;
1796 }
1797 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1798 CHECK(owner->result_ok);
1799         return RouteHint_clone(&*owner->contents.result);
1800 }
1801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1802         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1803         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1804         int64_t ret_ref = 0;
1805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1808         ret_ref = (uintptr_t)ret_var.inner;
1809         if (ret_var.is_owned) {
1810                 ret_ref |= 1;
1811         }
1812         return ret_ref;
1813 }
1814
1815 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1816 CHECK(!owner->result_ok);
1817         return DecodeError_clone(&*owner->contents.err);
1818 }
1819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1820         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1821         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1822         int64_t ret_ref = 0;
1823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1826         ret_ref = (uintptr_t)ret_var.inner;
1827         if (ret_var.is_owned) {
1828                 ret_ref |= 1;
1829         }
1830         return ret_ref;
1831 }
1832
1833 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1834 CHECK(owner->result_ok);
1835         return RouteHintHop_clone(&*owner->contents.result);
1836 }
1837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1838         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1839         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1840         int64_t ret_ref = 0;
1841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1844         ret_ref = (uintptr_t)ret_var.inner;
1845         if (ret_var.is_owned) {
1846                 ret_ref |= 1;
1847         }
1848         return ret_ref;
1849 }
1850
1851 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1852 CHECK(!owner->result_ok);
1853         return DecodeError_clone(&*owner->contents.err);
1854 }
1855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1856         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1857         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1858         int64_t ret_ref = 0;
1859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1862         ret_ref = (uintptr_t)ret_var.inner;
1863         if (ret_var.is_owned) {
1864                 ret_ref |= 1;
1865         }
1866         return ret_ref;
1867 }
1868
1869 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1870         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1871         for (size_t i = 0; i < ret.datalen; i++) {
1872                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1873         }
1874         return ret;
1875 }
1876 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1877 CHECK(owner->result_ok);
1878         return Route_clone(&*owner->contents.result);
1879 }
1880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1881         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1882         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1883         int64_t ret_ref = 0;
1884         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1885         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1887         ret_ref = (uintptr_t)ret_var.inner;
1888         if (ret_var.is_owned) {
1889                 ret_ref |= 1;
1890         }
1891         return ret_ref;
1892 }
1893
1894 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1895 CHECK(!owner->result_ok);
1896         return LightningError_clone(&*owner->contents.err);
1897 }
1898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1899         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1900         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1901         int64_t ret_ref = 0;
1902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1905         ret_ref = (uintptr_t)ret_var.inner;
1906         if (ret_var.is_owned) {
1907                 ret_ref |= 1;
1908         }
1909         return ret_ref;
1910 }
1911
1912 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1913 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1914 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1915 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1917         LDKPaymentPurpose_InvoicePayment_class =
1918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1919         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1920         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1921         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1922         LDKPaymentPurpose_SpontaneousPayment_class =
1923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1924         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1925         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1926         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1927 }
1928 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1929         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1930         switch(obj->tag) {
1931                 case LDKPaymentPurpose_InvoicePayment: {
1932                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1933                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1934                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1935                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1936                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1937                 }
1938                 case LDKPaymentPurpose_SpontaneousPayment: {
1939                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1940                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1941                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1942                 }
1943                 default: abort();
1944         }
1945 }
1946 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1947 CHECK(owner->result_ok);
1948         return PaymentPurpose_clone(&*owner->contents.result);
1949 }
1950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1951         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1952         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1953         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1954         int64_t ret_ref = (uintptr_t)ret_copy;
1955         return ret_ref;
1956 }
1957
1958 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1959 CHECK(!owner->result_ok);
1960         return DecodeError_clone(&*owner->contents.err);
1961 }
1962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1963         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1964         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1965         int64_t ret_ref = 0;
1966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1969         ret_ref = (uintptr_t)ret_var.inner;
1970         if (ret_var.is_owned) {
1971                 ret_ref |= 1;
1972         }
1973         return ret_ref;
1974 }
1975
1976 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1977 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1978 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1979 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1980 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1981 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1982 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1983 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1984 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1985 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1986 static jclass LDKClosureReason_ProcessingError_class = NULL;
1987 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1988 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1989 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1990 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1991 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1993         LDKClosureReason_CounterpartyForceClosed_class =
1994                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1995         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1996         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1997         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1998         LDKClosureReason_HolderForceClosed_class =
1999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2000         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2001         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2002         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2003         LDKClosureReason_CooperativeClosure_class =
2004                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2005         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2006         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2007         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2008         LDKClosureReason_CommitmentTxConfirmed_class =
2009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2010         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2011         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2012         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2013         LDKClosureReason_FundingTimedOut_class =
2014                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2015         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2016         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2017         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2018         LDKClosureReason_ProcessingError_class =
2019                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2020         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2021         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2022         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2023         LDKClosureReason_DisconnectedPeer_class =
2024                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2025         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2026         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2027         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2028         LDKClosureReason_OutdatedChannelManager_class =
2029                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2030         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2031         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2032         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2033 }
2034 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2035         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2036         switch(obj->tag) {
2037                 case LDKClosureReason_CounterpartyForceClosed: {
2038                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2039                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2040                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2041                 }
2042                 case LDKClosureReason_HolderForceClosed: {
2043                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2044                 }
2045                 case LDKClosureReason_CooperativeClosure: {
2046                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2047                 }
2048                 case LDKClosureReason_CommitmentTxConfirmed: {
2049                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2050                 }
2051                 case LDKClosureReason_FundingTimedOut: {
2052                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2053                 }
2054                 case LDKClosureReason_ProcessingError: {
2055                         LDKStr err_str = obj->processing_error.err;
2056                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2057                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2058                 }
2059                 case LDKClosureReason_DisconnectedPeer: {
2060                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2061                 }
2062                 case LDKClosureReason_OutdatedChannelManager: {
2063                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2064                 }
2065                 default: abort();
2066         }
2067 }
2068 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2069 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2070 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2071 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2073         LDKCOption_ClosureReasonZ_Some_class =
2074                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2075         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2076         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2077         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2078         LDKCOption_ClosureReasonZ_None_class =
2079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2080         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2081         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2082         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2083 }
2084 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2085         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2086         switch(obj->tag) {
2087                 case LDKCOption_ClosureReasonZ_Some: {
2088                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2089                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2090                 }
2091                 case LDKCOption_ClosureReasonZ_None: {
2092                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2093                 }
2094                 default: abort();
2095         }
2096 }
2097 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2098 CHECK(owner->result_ok);
2099         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2100 }
2101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2102         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2103         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2104         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2105         int64_t ret_ref = (uintptr_t)ret_copy;
2106         return ret_ref;
2107 }
2108
2109 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2110 CHECK(!owner->result_ok);
2111         return DecodeError_clone(&*owner->contents.err);
2112 }
2113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2114         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2115         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2116         int64_t ret_ref = 0;
2117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2120         ret_ref = (uintptr_t)ret_var.inner;
2121         if (ret_var.is_owned) {
2122                 ret_ref |= 1;
2123         }
2124         return ret_ref;
2125 }
2126
2127 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2128 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2129 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2130 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2131 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2132 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2134         LDKNetworkUpdate_ChannelUpdateMessage_class =
2135                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2136         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2137         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2138         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2139         LDKNetworkUpdate_ChannelFailure_class =
2140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2141         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2142         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2143         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2144         LDKNetworkUpdate_NodeFailure_class =
2145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2146         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2147         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2148         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2149 }
2150 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2151         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2152         switch(obj->tag) {
2153                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2154                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2155                         int64_t msg_ref = 0;
2156                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2157                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2158                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2159                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2160                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2161                 }
2162                 case LDKNetworkUpdate_ChannelFailure: {
2163                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2164                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2165                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2166                 }
2167                 case LDKNetworkUpdate_NodeFailure: {
2168                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2169                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2170                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2171                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2172                 }
2173                 default: abort();
2174         }
2175 }
2176 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2177 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2178 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2179 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2181         LDKCOption_NetworkUpdateZ_Some_class =
2182                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2183         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2184         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2185         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2186         LDKCOption_NetworkUpdateZ_None_class =
2187                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2188         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2189         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2190         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2191 }
2192 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2193         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2194         switch(obj->tag) {
2195                 case LDKCOption_NetworkUpdateZ_Some: {
2196                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2197                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2198                 }
2199                 case LDKCOption_NetworkUpdateZ_None: {
2200                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2201                 }
2202                 default: abort();
2203         }
2204 }
2205 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2206 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2207 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2208 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2209 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2210 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2212         LDKSpendableOutputDescriptor_StaticOutput_class =
2213                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2214         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2215         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2216         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2217         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2218                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2219         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2220         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2221         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2222         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2223                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2224         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2225         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2226         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2227 }
2228 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2229         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2230         switch(obj->tag) {
2231                 case LDKSpendableOutputDescriptor_StaticOutput: {
2232                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2233                         int64_t outpoint_ref = 0;
2234                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2235                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2236                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2237                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2238                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2239                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2240                 }
2241                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2242                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2243                         int64_t delayed_payment_output_ref = 0;
2244                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2245                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2246                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2247                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2248                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2249                 }
2250                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2251                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2252                         int64_t static_payment_output_ref = 0;
2253                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2254                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2256                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2257                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2258                 }
2259                 default: abort();
2260         }
2261 }
2262 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2263         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2264         for (size_t i = 0; i < ret.datalen; i++) {
2265                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2266         }
2267         return ret;
2268 }
2269 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2270 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2271 static jclass LDKEvent_PaymentReceived_class = NULL;
2272 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2273 static jclass LDKEvent_PaymentClaimed_class = NULL;
2274 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2275 static jclass LDKEvent_PaymentSent_class = NULL;
2276 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2277 static jclass LDKEvent_PaymentFailed_class = NULL;
2278 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2279 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2280 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2281 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2282 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2283 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2284 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2285 static jclass LDKEvent_SpendableOutputs_class = NULL;
2286 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2287 static jclass LDKEvent_PaymentForwarded_class = NULL;
2288 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2289 static jclass LDKEvent_ChannelClosed_class = NULL;
2290 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2291 static jclass LDKEvent_DiscardFunding_class = NULL;
2292 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2293 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2294 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2296         LDKEvent_FundingGenerationReady_class =
2297                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2298         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2299         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2300         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2301         LDKEvent_PaymentReceived_class =
2302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2303         CHECK(LDKEvent_PaymentReceived_class != NULL);
2304         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2305         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2306         LDKEvent_PaymentClaimed_class =
2307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2308         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2309         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2310         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2311         LDKEvent_PaymentSent_class =
2312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2313         CHECK(LDKEvent_PaymentSent_class != NULL);
2314         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2315         CHECK(LDKEvent_PaymentSent_meth != NULL);
2316         LDKEvent_PaymentFailed_class =
2317                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2318         CHECK(LDKEvent_PaymentFailed_class != NULL);
2319         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2320         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2321         LDKEvent_PaymentPathSuccessful_class =
2322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2323         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2324         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2325         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2326         LDKEvent_PaymentPathFailed_class =
2327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2328         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2329         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2330         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2331         LDKEvent_PendingHTLCsForwardable_class =
2332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2333         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2334         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2335         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2336         LDKEvent_SpendableOutputs_class =
2337                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2338         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2339         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2340         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2341         LDKEvent_PaymentForwarded_class =
2342                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2343         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2344         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2345         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2346         LDKEvent_ChannelClosed_class =
2347                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2348         CHECK(LDKEvent_ChannelClosed_class != NULL);
2349         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2350         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2351         LDKEvent_DiscardFunding_class =
2352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2353         CHECK(LDKEvent_DiscardFunding_class != NULL);
2354         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2355         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2356         LDKEvent_OpenChannelRequest_class =
2357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2358         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2359         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2360         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2361 }
2362 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2363         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2364         switch(obj->tag) {
2365                 case LDKEvent_FundingGenerationReady: {
2366                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2367                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2368                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2369                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2370                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2371                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2372                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2373                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2374                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2375                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2376                 }
2377                 case LDKEvent_PaymentReceived: {
2378                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2379                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2380                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2381                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2382                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2383                 }
2384                 case LDKEvent_PaymentClaimed: {
2385                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2386                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2387                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2388                         int64_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
2389                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2390                 }
2391                 case LDKEvent_PaymentSent: {
2392                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2393                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2394                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2395                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2396                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2397                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2398                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2399                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2400                 }
2401                 case LDKEvent_PaymentFailed: {
2402                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2403                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2404                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2405                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2406                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2407                 }
2408                 case LDKEvent_PaymentPathSuccessful: {
2409                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2410                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2411                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2412                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2413                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2414                         int64_tArray path_arr = NULL;
2415                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2416                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2417                         for (size_t k = 0; k < path_var.datalen; k++) {
2418                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2419                                 int64_t path_conv_10_ref = 0;
2420                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2421                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2422                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2423                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2424                                 path_arr_ptr[k] = path_conv_10_ref;
2425                         }
2426                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2427                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2428                 }
2429                 case LDKEvent_PaymentPathFailed: {
2430                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2431                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2432                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2433                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2434                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2435                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2436                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2437                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2438                         int64_tArray path_arr = NULL;
2439                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2440                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2441                         for (size_t k = 0; k < path_var.datalen; k++) {
2442                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2443                                 int64_t path_conv_10_ref = 0;
2444                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2445                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2446                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2447                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2448                                 path_arr_ptr[k] = path_conv_10_ref;
2449                         }
2450                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2451                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2452                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2453                         int64_t retry_ref = 0;
2454                         if ((uintptr_t)retry_var.inner > 4096) {
2455                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2456                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2457                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2458                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2459                         }
2460                         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);
2461                 }
2462                 case LDKEvent_PendingHTLCsForwardable: {
2463                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2464                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2465                 }
2466                 case LDKEvent_SpendableOutputs: {
2467                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2468                         int64_tArray outputs_arr = NULL;
2469                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2470                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2471                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2472                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2473                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2474                         }
2475                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2476                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2477                 }
2478                 case LDKEvent_PaymentForwarded: {
2479                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2480                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2481                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2482                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2483                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2484                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2485                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2486                 }
2487                 case LDKEvent_ChannelClosed: {
2488                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2489                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2490                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2491                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2492                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2493                 }
2494                 case LDKEvent_DiscardFunding: {
2495                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2496                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2497                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2498                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2499                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2500                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2501                 }
2502                 case LDKEvent_OpenChannelRequest: {
2503                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2504                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2505                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2506                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2507                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2508                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2509                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2510                         int64_t channel_type_ref = 0;
2511                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2512                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2513                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2514                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2515                         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);
2516                 }
2517                 default: abort();
2518         }
2519 }
2520 static jclass LDKCOption_EventZ_Some_class = NULL;
2521 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2522 static jclass LDKCOption_EventZ_None_class = NULL;
2523 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2525         LDKCOption_EventZ_Some_class =
2526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2527         CHECK(LDKCOption_EventZ_Some_class != NULL);
2528         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2529         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2530         LDKCOption_EventZ_None_class =
2531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2532         CHECK(LDKCOption_EventZ_None_class != NULL);
2533         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2534         CHECK(LDKCOption_EventZ_None_meth != NULL);
2535 }
2536 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2537         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2538         switch(obj->tag) {
2539                 case LDKCOption_EventZ_Some: {
2540                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2541                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2542                 }
2543                 case LDKCOption_EventZ_None: {
2544                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2545                 }
2546                 default: abort();
2547         }
2548 }
2549 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2550 CHECK(owner->result_ok);
2551         return COption_EventZ_clone(&*owner->contents.result);
2552 }
2553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2554         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2555         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2556         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2557         int64_t ret_ref = (uintptr_t)ret_copy;
2558         return ret_ref;
2559 }
2560
2561 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2562 CHECK(!owner->result_ok);
2563         return DecodeError_clone(&*owner->contents.err);
2564 }
2565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2566         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2567         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2568         int64_t ret_ref = 0;
2569         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2570         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2572         ret_ref = (uintptr_t)ret_var.inner;
2573         if (ret_var.is_owned) {
2574                 ret_ref |= 1;
2575         }
2576         return ret_ref;
2577 }
2578
2579 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2580 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2581 static jclass LDKErrorAction_IgnoreError_class = NULL;
2582 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2583 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2584 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2585 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2586 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2587 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2588 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2589 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2590 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2592         LDKErrorAction_DisconnectPeer_class =
2593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2594         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2595         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2596         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2597         LDKErrorAction_IgnoreError_class =
2598                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2599         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2600         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2601         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2602         LDKErrorAction_IgnoreAndLog_class =
2603                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2604         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2605         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2606         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2607         LDKErrorAction_IgnoreDuplicateGossip_class =
2608                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2609         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2610         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2611         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2612         LDKErrorAction_SendErrorMessage_class =
2613                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2614         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2615         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2616         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2617         LDKErrorAction_SendWarningMessage_class =
2618                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2619         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2620         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2621         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2622 }
2623 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2624         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2625         switch(obj->tag) {
2626                 case LDKErrorAction_DisconnectPeer: {
2627                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2628                         int64_t msg_ref = 0;
2629                         if ((uintptr_t)msg_var.inner > 4096) {
2630                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2631                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2632                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2633                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2634                         }
2635                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2636                 }
2637                 case LDKErrorAction_IgnoreError: {
2638                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2639                 }
2640                 case LDKErrorAction_IgnoreAndLog: {
2641                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2642                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2643                 }
2644                 case LDKErrorAction_IgnoreDuplicateGossip: {
2645                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2646                 }
2647                 case LDKErrorAction_SendErrorMessage: {
2648                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2649                         int64_t msg_ref = 0;
2650                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2651                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2652                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2653                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2654                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2655                 }
2656                 case LDKErrorAction_SendWarningMessage: {
2657                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2658                         int64_t msg_ref = 0;
2659                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2660                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2661                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2662                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2663                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2664                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2665                 }
2666                 default: abort();
2667         }
2668 }
2669 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2670 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2671 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2672 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2673 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2674 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2675 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2676 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2677 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2678 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2679 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2680 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2681 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2682 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2683 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2684 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2685 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2686 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2687 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2688 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2689 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2690 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2691 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2692 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2693 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2694 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2695 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2696 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2697 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2698 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2699 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2700 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2701 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2702 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2703 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2704 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2705 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2706 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2707 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2708 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2710         LDKMessageSendEvent_SendAcceptChannel_class =
2711                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2712         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2713         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2714         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2715         LDKMessageSendEvent_SendOpenChannel_class =
2716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2717         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2718         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2719         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2720         LDKMessageSendEvent_SendFundingCreated_class =
2721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2722         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2723         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2724         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2725         LDKMessageSendEvent_SendFundingSigned_class =
2726                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2727         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2728         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2729         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2730         LDKMessageSendEvent_SendChannelReady_class =
2731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2732         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2733         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2734         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2735         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2737         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2738         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2739         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2740         LDKMessageSendEvent_UpdateHTLCs_class =
2741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2742         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2743         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2744         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2745         LDKMessageSendEvent_SendRevokeAndACK_class =
2746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2747         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2748         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2749         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2750         LDKMessageSendEvent_SendClosingSigned_class =
2751                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2752         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2753         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2754         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2755         LDKMessageSendEvent_SendShutdown_class =
2756                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2757         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2758         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2759         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2760         LDKMessageSendEvent_SendChannelReestablish_class =
2761                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2762         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2763         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2764         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2765         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2766                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2767         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2768         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2769         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2770         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2771                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2772         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2773         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2774         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2775         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2776                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2777         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2778         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2779         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2780         LDKMessageSendEvent_SendChannelUpdate_class =
2781                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2782         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2783         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2784         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2785         LDKMessageSendEvent_HandleError_class =
2786                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2787         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2788         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2789         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2790         LDKMessageSendEvent_SendChannelRangeQuery_class =
2791                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2792         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2793         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2794         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2795         LDKMessageSendEvent_SendShortIdsQuery_class =
2796                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2797         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2798         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2799         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2800         LDKMessageSendEvent_SendReplyChannelRange_class =
2801                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2802         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2803         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2804         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2805         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2806                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2807         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2808         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2809         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2810 }
2811 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2812         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2813         switch(obj->tag) {
2814                 case LDKMessageSendEvent_SendAcceptChannel: {
2815                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2816                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2817                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2818                         int64_t msg_ref = 0;
2819                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2820                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2821                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2822                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2823                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2824                 }
2825                 case LDKMessageSendEvent_SendOpenChannel: {
2826                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2827                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2828                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2829                         int64_t msg_ref = 0;
2830                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2831                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2832                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2833                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2834                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2835                 }
2836                 case LDKMessageSendEvent_SendFundingCreated: {
2837                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2838                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2839                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2840                         int64_t msg_ref = 0;
2841                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2842                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2843                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2844                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2845                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2846                 }
2847                 case LDKMessageSendEvent_SendFundingSigned: {
2848                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2849                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2850                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2851                         int64_t msg_ref = 0;
2852                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2853                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2854                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2855                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2856                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2857                 }
2858                 case LDKMessageSendEvent_SendChannelReady: {
2859                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2860                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
2861                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2862                         int64_t msg_ref = 0;
2863                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2864                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2865                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2866                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2867                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
2868                 }
2869                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2870                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2871                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2872                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2873                         int64_t msg_ref = 0;
2874                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2875                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2876                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2877                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2878                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2879                 }
2880                 case LDKMessageSendEvent_UpdateHTLCs: {
2881                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2882                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2883                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2884                         int64_t updates_ref = 0;
2885                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2886                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2887                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2888                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2889                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2890                 }
2891                 case LDKMessageSendEvent_SendRevokeAndACK: {
2892                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2893                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2894                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2895                         int64_t msg_ref = 0;
2896                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2897                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2898                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2899                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2900                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2901                 }
2902                 case LDKMessageSendEvent_SendClosingSigned: {
2903                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2904                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2905                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2906                         int64_t msg_ref = 0;
2907                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2908                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2909                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2910                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2911                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2912                 }
2913                 case LDKMessageSendEvent_SendShutdown: {
2914                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2915                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2916                         LDKShutdown msg_var = obj->send_shutdown.msg;
2917                         int64_t msg_ref = 0;
2918                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2919                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2920                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2921                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2922                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2923                 }
2924                 case LDKMessageSendEvent_SendChannelReestablish: {
2925                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2926                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2927                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2928                         int64_t msg_ref = 0;
2929                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2930                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2931                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2932                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2933                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2934                 }
2935                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2936                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2937                         int64_t msg_ref = 0;
2938                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2939                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2940                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2941                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2942                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2943                         int64_t update_msg_ref = 0;
2944                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2945                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2946                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2947                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2948                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2949                 }
2950                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2951                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.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_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2958                 }
2959                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2960                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2961                         int64_t msg_ref = 0;
2962                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2963                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2964                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2965                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2966                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2967                 }
2968                 case LDKMessageSendEvent_SendChannelUpdate: {
2969                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2970                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2971                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2972                         int64_t msg_ref = 0;
2973                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2974                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2975                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2976                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2977                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2978                 }
2979                 case LDKMessageSendEvent_HandleError: {
2980                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2981                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2982                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2983                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2984                 }
2985                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2986                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2987                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2988                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2989                         int64_t msg_ref = 0;
2990                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2991                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2992                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2993                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2994                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2995                 }
2996                 case LDKMessageSendEvent_SendShortIdsQuery: {
2997                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2998                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2999                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3000                         int64_t msg_ref = 0;
3001                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3002                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3003                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3004                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3005                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3006                 }
3007                 case LDKMessageSendEvent_SendReplyChannelRange: {
3008                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3009                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3010                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3011                         int64_t msg_ref = 0;
3012                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3013                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3014                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3015                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3016                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3017                 }
3018                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3019                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3020                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3021                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3022                         int64_t msg_ref = 0;
3023                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3024                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3025                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3026                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3027                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3028                 }
3029                 default: abort();
3030         }
3031 }
3032 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3033         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3034         for (size_t i = 0; i < ret.datalen; i++) {
3035                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3036         }
3037         return ret;
3038 }
3039 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3040 CHECK(owner->result_ok);
3041         return TxOut_clone(&*owner->contents.result);
3042 }
3043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3044         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3045         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3046         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3047         return (int64_t)ret_ref;
3048 }
3049
3050 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3051 CHECK(!owner->result_ok);
3052         return AccessError_clone(&*owner->contents.err);
3053 }
3054 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3055         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3056         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3057         return ret_conv;
3058 }
3059
3060 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3061         return owner->a;
3062 }
3063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3064         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3065         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3066         return ret_conv;
3067 }
3068
3069 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3070         return owner->b;
3071 }
3072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3073         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3074         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3077         return ret_arr;
3078 }
3079
3080 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3081         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3082         for (size_t i = 0; i < ret.datalen; i++) {
3083                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3084         }
3085         return ret;
3086 }
3087 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3088         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3089         for (size_t i = 0; i < ret.datalen; i++) {
3090                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3091         }
3092         return ret;
3093 }
3094 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3095 CHECK(owner->result_ok);
3096         return *owner->contents.result;
3097 }
3098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3099         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3100         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3101 }
3102
3103 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3104 CHECK(!owner->result_ok);
3105         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3106 }
3107 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3108         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3109         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3110         return ret_conv;
3111 }
3112
3113 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3114 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3115 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3116 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3117 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3118 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3119 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3120 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3122         LDKMonitorEvent_HTLCEvent_class =
3123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3124         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3125         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3126         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3127         LDKMonitorEvent_CommitmentTxConfirmed_class =
3128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3129         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3130         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3131         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3132         LDKMonitorEvent_UpdateCompleted_class =
3133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3134         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3135         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3136         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3137         LDKMonitorEvent_UpdateFailed_class =
3138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3139         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3140         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3141         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3142 }
3143 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3144         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
3145         switch(obj->tag) {
3146                 case LDKMonitorEvent_HTLCEvent: {
3147                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3148                         int64_t htlc_event_ref = 0;
3149                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3150                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3151                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3152                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
3153                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3154                 }
3155                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3156                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3157                         int64_t commitment_tx_confirmed_ref = 0;
3158                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3159                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3160                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3161                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
3162                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3163                 }
3164                 case LDKMonitorEvent_UpdateCompleted: {
3165                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3166                         int64_t funding_txo_ref = 0;
3167                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3168                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3169                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3170                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
3171                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3172                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3173                 }
3174                 case LDKMonitorEvent_UpdateFailed: {
3175                         LDKOutPoint update_failed_var = obj->update_failed;
3176                         int64_t update_failed_ref = 0;
3177                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3178                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3179                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3180                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
3181                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3182                 }
3183                 default: abort();
3184         }
3185 }
3186 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3187         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3188         for (size_t i = 0; i < ret.datalen; i++) {
3189                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3190         }
3191         return ret;
3192 }
3193 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorEventZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
3194         return OutPoint_clone(&owner->a);
3195 }
3196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3197         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
3198         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_a(owner_conv);
3199         int64_t ret_ref = 0;
3200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3203         ret_ref = (uintptr_t)ret_var.inner;
3204         if (ret_var.is_owned) {
3205                 ret_ref |= 1;
3206         }
3207         return ret_ref;
3208 }
3209
3210 static inline struct LDKCVec_MonitorEventZ C2Tuple_OutPointCVec_MonitorEventZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
3211         return CVec_MonitorEventZ_clone(&owner->b);
3212 }
3213 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3214         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
3215         LDKCVec_MonitorEventZ ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_b(owner_conv);
3216         int64_tArray ret_arr = NULL;
3217         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3218         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3219         for (size_t o = 0; o < ret_var.datalen; o++) {
3220                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3221                 *ret_conv_14_copy = ret_var.data[o];
3222                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
3223                 ret_arr_ptr[o] = ret_conv_14_ref;
3224         }
3225         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3226         FREE(ret_var.data);
3227         return ret_arr;
3228 }
3229
3230 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ *orig) {
3231         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ clone bytes"), .datalen = orig->datalen };
3232         for (size_t i = 0; i < ret.datalen; i++) {
3233                 ret.data[i] = C2Tuple_OutPointCVec_MonitorEventZZ_clone(&orig->data[i]);
3234         }
3235         return ret;
3236 }
3237 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3238 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3239 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3240 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3242         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3243                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3244         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3245         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3246         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3247         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3248                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3249         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3250         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3251         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3252 }
3253 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3254         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3255         switch(obj->tag) {
3256                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3257                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3258                         *some_conv = obj->some;
3259                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3260                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
3261                 }
3262                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3263                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3264                 }
3265                 default: abort();
3266         }
3267 }
3268 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3269 CHECK(owner->result_ok);
3270         return FixedPenaltyScorer_clone(&*owner->contents.result);
3271 }
3272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3273         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3274         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3275         int64_t ret_ref = 0;
3276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3279         ret_ref = (uintptr_t)ret_var.inner;
3280         if (ret_var.is_owned) {
3281                 ret_ref |= 1;
3282         }
3283         return ret_ref;
3284 }
3285
3286 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3287 CHECK(!owner->result_ok);
3288         return DecodeError_clone(&*owner->contents.err);
3289 }
3290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3291         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3292         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3293         int64_t ret_ref = 0;
3294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3297         ret_ref = (uintptr_t)ret_var.inner;
3298         if (ret_var.is_owned) {
3299                 ret_ref |= 1;
3300         }
3301         return ret_ref;
3302 }
3303
3304 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3305         return owner->a;
3306 }
3307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3308         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3309         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3310         return ret_conv;
3311 }
3312
3313 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3314         return owner->b;
3315 }
3316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3317         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3318         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3319         return ret_conv;
3320 }
3321
3322 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3323 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3324 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3325 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3327         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3328                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3329         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3330         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3331         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3332         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3333                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3334         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3335         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3336         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3337 }
3338 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3339         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
3340         switch(obj->tag) {
3341                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3342                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3343                         *some_conv = obj->some;
3344                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3345                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, ((int64_t)some_conv));
3346                 }
3347                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3348                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3349                 }
3350                 default: abort();
3351         }
3352 }
3353 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3354         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3355         for (size_t i = 0; i < ret.datalen; i++) {
3356                 ret.data[i] = NodeId_clone(&orig->data[i]);
3357         }
3358         return ret;
3359 }
3360 typedef struct LDKLogger_JCalls {
3361         atomic_size_t refcnt;
3362         JavaVM *vm;
3363         jweak o;
3364         jmethodID log_meth;
3365 } LDKLogger_JCalls;
3366 static void LDKLogger_JCalls_free(void* this_arg) {
3367         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3368         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3369                 JNIEnv *env;
3370                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3371                 if (get_jenv_res == JNI_EDETACHED) {
3372                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3373                 } else {
3374                         DO_ASSERT(get_jenv_res == JNI_OK);
3375                 }
3376                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3377                 if (get_jenv_res == JNI_EDETACHED) {
3378                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3379                 }
3380                 FREE(j_calls);
3381         }
3382 }
3383 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3384         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3385         JNIEnv *env;
3386         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3387         if (get_jenv_res == JNI_EDETACHED) {
3388                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3389         } else {
3390                 DO_ASSERT(get_jenv_res == JNI_OK);
3391         }
3392         LDKRecord record_var = *record;
3393         int64_t record_ref = 0;
3394         record_var = Record_clone(&record_var);
3395         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3396         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3397         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3398         record_ref = (uintptr_t)record_var.inner;
3399         if (record_var.is_owned) {
3400                 record_ref |= 1;
3401         }
3402         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3403         CHECK(obj != NULL);
3404         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3405         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3406                 (*env)->ExceptionDescribe(env);
3407                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3408         }
3409         if (get_jenv_res == JNI_EDETACHED) {
3410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3411         }
3412 }
3413 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3414         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3415         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3416 }
3417 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3418         jclass c = (*env)->GetObjectClass(env, o);
3419         CHECK(c != NULL);
3420         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3421         atomic_init(&calls->refcnt, 1);
3422         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3423         calls->o = (*env)->NewWeakGlobalRef(env, o);
3424         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3425         CHECK(calls->log_meth != NULL);
3426
3427         LDKLogger ret = {
3428                 .this_arg = (void*) calls,
3429                 .log = log_LDKLogger_jcall,
3430                 .free = LDKLogger_JCalls_free,
3431         };
3432         return ret;
3433 }
3434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3435         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3436         *res_ptr = LDKLogger_init(env, clz, o);
3437         return (uint64_t)res_ptr;
3438 }
3439 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3440 CHECK(owner->result_ok);
3441         return &*owner->contents.result;
3442 }
3443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3444         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3445         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3446         int64_t ret_ref = 0;
3447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3450         ret_ref = (uintptr_t)ret_var.inner & ~1;
3451         return ret_ref;
3452 }
3453
3454 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3455 CHECK(!owner->result_ok);
3456         return DecodeError_clone(&*owner->contents.err);
3457 }
3458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3459         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3460         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3461         int64_t ret_ref = 0;
3462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3465         ret_ref = (uintptr_t)ret_var.inner;
3466         if (ret_var.is_owned) {
3467                 ret_ref |= 1;
3468         }
3469         return ret_ref;
3470 }
3471
3472 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3473 CHECK(owner->result_ok);
3474         return InitFeatures_clone(&*owner->contents.result);
3475 }
3476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3477         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3478         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3479         int64_t ret_ref = 0;
3480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3483         ret_ref = (uintptr_t)ret_var.inner;
3484         if (ret_var.is_owned) {
3485                 ret_ref |= 1;
3486         }
3487         return ret_ref;
3488 }
3489
3490 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3491 CHECK(!owner->result_ok);
3492         return DecodeError_clone(&*owner->contents.err);
3493 }
3494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3495         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3496         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3497         int64_t ret_ref = 0;
3498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3501         ret_ref = (uintptr_t)ret_var.inner;
3502         if (ret_var.is_owned) {
3503                 ret_ref |= 1;
3504         }
3505         return ret_ref;
3506 }
3507
3508 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3509 CHECK(owner->result_ok);
3510         return ChannelFeatures_clone(&*owner->contents.result);
3511 }
3512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3513         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3514         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3515         int64_t ret_ref = 0;
3516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3519         ret_ref = (uintptr_t)ret_var.inner;
3520         if (ret_var.is_owned) {
3521                 ret_ref |= 1;
3522         }
3523         return ret_ref;
3524 }
3525
3526 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3527 CHECK(!owner->result_ok);
3528         return DecodeError_clone(&*owner->contents.err);
3529 }
3530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3531         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3532         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3533         int64_t ret_ref = 0;
3534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3537         ret_ref = (uintptr_t)ret_var.inner;
3538         if (ret_var.is_owned) {
3539                 ret_ref |= 1;
3540         }
3541         return ret_ref;
3542 }
3543
3544 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3545 CHECK(owner->result_ok);
3546         return NodeFeatures_clone(&*owner->contents.result);
3547 }
3548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3549         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3550         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3551         int64_t ret_ref = 0;
3552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3555         ret_ref = (uintptr_t)ret_var.inner;
3556         if (ret_var.is_owned) {
3557                 ret_ref |= 1;
3558         }
3559         return ret_ref;
3560 }
3561
3562 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3563 CHECK(!owner->result_ok);
3564         return DecodeError_clone(&*owner->contents.err);
3565 }
3566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3567         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3568         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3569         int64_t ret_ref = 0;
3570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3573         ret_ref = (uintptr_t)ret_var.inner;
3574         if (ret_var.is_owned) {
3575                 ret_ref |= 1;
3576         }
3577         return ret_ref;
3578 }
3579
3580 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3581 CHECK(owner->result_ok);
3582         return InvoiceFeatures_clone(&*owner->contents.result);
3583 }
3584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3585         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3586         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3587         int64_t ret_ref = 0;
3588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3591         ret_ref = (uintptr_t)ret_var.inner;
3592         if (ret_var.is_owned) {
3593                 ret_ref |= 1;
3594         }
3595         return ret_ref;
3596 }
3597
3598 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3599 CHECK(!owner->result_ok);
3600         return DecodeError_clone(&*owner->contents.err);
3601 }
3602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3603         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3604         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3605         int64_t ret_ref = 0;
3606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3609         ret_ref = (uintptr_t)ret_var.inner;
3610         if (ret_var.is_owned) {
3611                 ret_ref |= 1;
3612         }
3613         return ret_ref;
3614 }
3615
3616 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3617 CHECK(owner->result_ok);
3618         return ChannelTypeFeatures_clone(&*owner->contents.result);
3619 }
3620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3621         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3622         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3623         int64_t ret_ref = 0;
3624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3627         ret_ref = (uintptr_t)ret_var.inner;
3628         if (ret_var.is_owned) {
3629                 ret_ref |= 1;
3630         }
3631         return ret_ref;
3632 }
3633
3634 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3635 CHECK(!owner->result_ok);
3636         return DecodeError_clone(&*owner->contents.err);
3637 }
3638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3639         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3640         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3641         int64_t ret_ref = 0;
3642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3645         ret_ref = (uintptr_t)ret_var.inner;
3646         if (ret_var.is_owned) {
3647                 ret_ref |= 1;
3648         }
3649         return ret_ref;
3650 }
3651
3652 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3653 CHECK(owner->result_ok);
3654         return NodeId_clone(&*owner->contents.result);
3655 }
3656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3657         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3658         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3659         int64_t ret_ref = 0;
3660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3663         ret_ref = (uintptr_t)ret_var.inner;
3664         if (ret_var.is_owned) {
3665                 ret_ref |= 1;
3666         }
3667         return ret_ref;
3668 }
3669
3670 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3671 CHECK(!owner->result_ok);
3672         return DecodeError_clone(&*owner->contents.err);
3673 }
3674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3675         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3676         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3677         int64_t ret_ref = 0;
3678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3681         ret_ref = (uintptr_t)ret_var.inner;
3682         if (ret_var.is_owned) {
3683                 ret_ref |= 1;
3684         }
3685         return ret_ref;
3686 }
3687
3688 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3689 CHECK(owner->result_ok);
3690         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3691 }
3692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3693         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3694         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3695         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3696         int64_t ret_ref = (uintptr_t)ret_copy;
3697         return ret_ref;
3698 }
3699
3700 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3701 CHECK(!owner->result_ok);
3702         return DecodeError_clone(&*owner->contents.err);
3703 }
3704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3705         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3706         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3707         int64_t ret_ref = 0;
3708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3711         ret_ref = (uintptr_t)ret_var.inner;
3712         if (ret_var.is_owned) {
3713                 ret_ref |= 1;
3714         }
3715         return ret_ref;
3716 }
3717
3718 typedef struct LDKAccess_JCalls {
3719         atomic_size_t refcnt;
3720         JavaVM *vm;
3721         jweak o;
3722         jmethodID get_utxo_meth;
3723 } LDKAccess_JCalls;
3724 static void LDKAccess_JCalls_free(void* this_arg) {
3725         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3726         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3727                 JNIEnv *env;
3728                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3729                 if (get_jenv_res == JNI_EDETACHED) {
3730                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3731                 } else {
3732                         DO_ASSERT(get_jenv_res == JNI_OK);
3733                 }
3734                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3735                 if (get_jenv_res == JNI_EDETACHED) {
3736                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3737                 }
3738                 FREE(j_calls);
3739         }
3740 }
3741 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3742         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3743         JNIEnv *env;
3744         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3745         if (get_jenv_res == JNI_EDETACHED) {
3746                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3747         } else {
3748                 DO_ASSERT(get_jenv_res == JNI_OK);
3749         }
3750         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3751         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3752         int64_t short_channel_id_conv = short_channel_id;
3753         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3754         CHECK(obj != NULL);
3755         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3756         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3757                 (*env)->ExceptionDescribe(env);
3758                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3759         }
3760         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3761         CHECK_ACCESS(ret_ptr);
3762         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3763         FREE((void*)ret);
3764         if (get_jenv_res == JNI_EDETACHED) {
3765                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3766         }
3767         return ret_conv;
3768 }
3769 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3770         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3771         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3772 }
3773 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3774         jclass c = (*env)->GetObjectClass(env, o);
3775         CHECK(c != NULL);
3776         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3777         atomic_init(&calls->refcnt, 1);
3778         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3779         calls->o = (*env)->NewWeakGlobalRef(env, o);
3780         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3781         CHECK(calls->get_utxo_meth != NULL);
3782
3783         LDKAccess ret = {
3784                 .this_arg = (void*) calls,
3785                 .get_utxo = get_utxo_LDKAccess_jcall,
3786                 .free = LDKAccess_JCalls_free,
3787         };
3788         return ret;
3789 }
3790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3791         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3792         *res_ptr = LDKAccess_init(env, clz, o);
3793         return (uint64_t)res_ptr;
3794 }
3795 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) {
3796         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3797         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3798         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3799         unsigned char genesis_hash_arr[32];
3800         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3801         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3802         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3803         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3804         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3805         return (int64_t)ret_conv;
3806 }
3807
3808 static jclass LDKCOption_AccessZ_Some_class = NULL;
3809 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3810 static jclass LDKCOption_AccessZ_None_class = NULL;
3811 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
3812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
3813         LDKCOption_AccessZ_Some_class =
3814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
3815         CHECK(LDKCOption_AccessZ_Some_class != NULL);
3816         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
3817         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
3818         LDKCOption_AccessZ_None_class =
3819                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
3820         CHECK(LDKCOption_AccessZ_None_class != NULL);
3821         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
3822         CHECK(LDKCOption_AccessZ_None_meth != NULL);
3823 }
3824 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3825         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3826         switch(obj->tag) {
3827                 case LDKCOption_AccessZ_Some: {
3828                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3829                         *some_ret = obj->some;
3830                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3831                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3832                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3833                                 LDKAccess_JCalls_cloned(&(*some_ret));
3834                         }
3835                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
3836                 }
3837                 case LDKCOption_AccessZ_None: {
3838                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
3839                 }
3840                 default: abort();
3841         }
3842 }
3843 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3844 CHECK(owner->result_ok);
3845         return *owner->contents.result;
3846 }
3847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3848         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3849         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3850         return ret_conv;
3851 }
3852
3853 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3854 CHECK(!owner->result_ok);
3855         return LightningError_clone(&*owner->contents.err);
3856 }
3857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3858         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3859         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3860         int64_t ret_ref = 0;
3861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3864         ret_ref = (uintptr_t)ret_var.inner;
3865         if (ret_var.is_owned) {
3866                 ret_ref |= 1;
3867         }
3868         return ret_ref;
3869 }
3870
3871 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3872         return ChannelAnnouncement_clone(&owner->a);
3873 }
3874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3875         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3876         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3877         int64_t ret_ref = 0;
3878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3881         ret_ref = (uintptr_t)ret_var.inner;
3882         if (ret_var.is_owned) {
3883                 ret_ref |= 1;
3884         }
3885         return ret_ref;
3886 }
3887
3888 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3889         return ChannelUpdate_clone(&owner->b);
3890 }
3891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3892         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3893         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3894         int64_t ret_ref = 0;
3895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3898         ret_ref = (uintptr_t)ret_var.inner;
3899         if (ret_var.is_owned) {
3900                 ret_ref |= 1;
3901         }
3902         return ret_ref;
3903 }
3904
3905 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3906         return ChannelUpdate_clone(&owner->c);
3907 }
3908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3909         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3910         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3911         int64_t ret_ref = 0;
3912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3915         ret_ref = (uintptr_t)ret_var.inner;
3916         if (ret_var.is_owned) {
3917                 ret_ref |= 1;
3918         }
3919         return ret_ref;
3920 }
3921
3922 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3923         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3924         for (size_t i = 0; i < ret.datalen; i++) {
3925                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3926         }
3927         return ret;
3928 }
3929 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3930         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3931         for (size_t i = 0; i < ret.datalen; i++) {
3932                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3933         }
3934         return ret;
3935 }
3936 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3937 CHECK(owner->result_ok);
3938         return *owner->contents.result;
3939 }
3940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3941         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3942         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3943 }
3944
3945 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3946 CHECK(!owner->result_ok);
3947         return LightningError_clone(&*owner->contents.err);
3948 }
3949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3950         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3951         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3952         int64_t ret_ref = 0;
3953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3956         ret_ref = (uintptr_t)ret_var.inner;
3957         if (ret_var.is_owned) {
3958                 ret_ref |= 1;
3959         }
3960         return ret_ref;
3961 }
3962
3963 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3964 CHECK(owner->result_ok);
3965         return ChannelUpdateInfo_clone(&*owner->contents.result);
3966 }
3967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3968         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3969         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3970         int64_t ret_ref = 0;
3971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3974         ret_ref = (uintptr_t)ret_var.inner;
3975         if (ret_var.is_owned) {
3976                 ret_ref |= 1;
3977         }
3978         return ret_ref;
3979 }
3980
3981 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3982 CHECK(!owner->result_ok);
3983         return DecodeError_clone(&*owner->contents.err);
3984 }
3985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3986         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3987         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3988         int64_t ret_ref = 0;
3989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3992         ret_ref = (uintptr_t)ret_var.inner;
3993         if (ret_var.is_owned) {
3994                 ret_ref |= 1;
3995         }
3996         return ret_ref;
3997 }
3998
3999 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4000 CHECK(owner->result_ok);
4001         return ChannelInfo_clone(&*owner->contents.result);
4002 }
4003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4004         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4005         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4006         int64_t ret_ref = 0;
4007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4010         ret_ref = (uintptr_t)ret_var.inner;
4011         if (ret_var.is_owned) {
4012                 ret_ref |= 1;
4013         }
4014         return ret_ref;
4015 }
4016
4017 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4018 CHECK(!owner->result_ok);
4019         return DecodeError_clone(&*owner->contents.err);
4020 }
4021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4022         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4023         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4024         int64_t ret_ref = 0;
4025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4028         ret_ref = (uintptr_t)ret_var.inner;
4029         if (ret_var.is_owned) {
4030                 ret_ref |= 1;
4031         }
4032         return ret_ref;
4033 }
4034
4035 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4036 CHECK(owner->result_ok);
4037         return RoutingFees_clone(&*owner->contents.result);
4038 }
4039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4040         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4041         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4042         int64_t ret_ref = 0;
4043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4046         ret_ref = (uintptr_t)ret_var.inner;
4047         if (ret_var.is_owned) {
4048                 ret_ref |= 1;
4049         }
4050         return ret_ref;
4051 }
4052
4053 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4054 CHECK(!owner->result_ok);
4055         return DecodeError_clone(&*owner->contents.err);
4056 }
4057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4058         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4059         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4060         int64_t ret_ref = 0;
4061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4064         ret_ref = (uintptr_t)ret_var.inner;
4065         if (ret_var.is_owned) {
4066                 ret_ref |= 1;
4067         }
4068         return ret_ref;
4069 }
4070
4071 static jclass LDKNetAddress_IPv4_class = NULL;
4072 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4073 static jclass LDKNetAddress_IPv6_class = NULL;
4074 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4075 static jclass LDKNetAddress_OnionV2_class = NULL;
4076 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4077 static jclass LDKNetAddress_OnionV3_class = NULL;
4078 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4080         LDKNetAddress_IPv4_class =
4081                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4082         CHECK(LDKNetAddress_IPv4_class != NULL);
4083         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4084         CHECK(LDKNetAddress_IPv4_meth != NULL);
4085         LDKNetAddress_IPv6_class =
4086                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4087         CHECK(LDKNetAddress_IPv6_class != NULL);
4088         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4089         CHECK(LDKNetAddress_IPv6_meth != NULL);
4090         LDKNetAddress_OnionV2_class =
4091                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4092         CHECK(LDKNetAddress_OnionV2_class != NULL);
4093         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4094         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4095         LDKNetAddress_OnionV3_class =
4096                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4097         CHECK(LDKNetAddress_OnionV3_class != NULL);
4098         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4099         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4100 }
4101 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4102         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4103         switch(obj->tag) {
4104                 case LDKNetAddress_IPv4: {
4105                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4106                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4107                         int16_t port_conv = obj->i_pv4.port;
4108                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4109                 }
4110                 case LDKNetAddress_IPv6: {
4111                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4112                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4113                         int16_t port_conv = obj->i_pv6.port;
4114                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4115                 }
4116                 case LDKNetAddress_OnionV2: {
4117                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4118                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4119                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4120                 }
4121                 case LDKNetAddress_OnionV3: {
4122                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4123                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4124                         int16_t checksum_conv = obj->onion_v3.checksum;
4125                         int8_t version_conv = obj->onion_v3.version;
4126                         int16_t port_conv = obj->onion_v3.port;
4127                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4128                 }
4129                 default: abort();
4130         }
4131 }
4132 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4133         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4134         for (size_t i = 0; i < ret.datalen; i++) {
4135                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4136         }
4137         return ret;
4138 }
4139 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4140 CHECK(owner->result_ok);
4141         return NodeAnnouncementInfo_clone(&*owner->contents.result);
4142 }
4143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4144         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4145         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4146         int64_t ret_ref = 0;
4147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4150         ret_ref = (uintptr_t)ret_var.inner;
4151         if (ret_var.is_owned) {
4152                 ret_ref |= 1;
4153         }
4154         return ret_ref;
4155 }
4156
4157 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4158 CHECK(!owner->result_ok);
4159         return DecodeError_clone(&*owner->contents.err);
4160 }
4161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4162         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4163         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4164         int64_t ret_ref = 0;
4165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4168         ret_ref = (uintptr_t)ret_var.inner;
4169         if (ret_var.is_owned) {
4170                 ret_ref |= 1;
4171         }
4172         return ret_ref;
4173 }
4174
4175 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4176 CHECK(owner->result_ok);
4177         return NodeAlias_clone(&*owner->contents.result);
4178 }
4179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4180         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4181         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4182         int64_t ret_ref = 0;
4183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4186         ret_ref = (uintptr_t)ret_var.inner;
4187         if (ret_var.is_owned) {
4188                 ret_ref |= 1;
4189         }
4190         return ret_ref;
4191 }
4192
4193 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4194 CHECK(!owner->result_ok);
4195         return DecodeError_clone(&*owner->contents.err);
4196 }
4197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4198         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4199         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4200         int64_t ret_ref = 0;
4201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4204         ret_ref = (uintptr_t)ret_var.inner;
4205         if (ret_var.is_owned) {
4206                 ret_ref |= 1;
4207         }
4208         return ret_ref;
4209 }
4210
4211 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4212         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4213         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4214         return ret;
4215 }
4216 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4217 CHECK(owner->result_ok);
4218         return NodeInfo_clone(&*owner->contents.result);
4219 }
4220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4221         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4222         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4223         int64_t ret_ref = 0;
4224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4227         ret_ref = (uintptr_t)ret_var.inner;
4228         if (ret_var.is_owned) {
4229                 ret_ref |= 1;
4230         }
4231         return ret_ref;
4232 }
4233
4234 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4235 CHECK(!owner->result_ok);
4236         return DecodeError_clone(&*owner->contents.err);
4237 }
4238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4239         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4240         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4241         int64_t ret_ref = 0;
4242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4245         ret_ref = (uintptr_t)ret_var.inner;
4246         if (ret_var.is_owned) {
4247                 ret_ref |= 1;
4248         }
4249         return ret_ref;
4250 }
4251
4252 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4253 CHECK(owner->result_ok);
4254         return &*owner->contents.result;
4255 }
4256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4257         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4258         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4259         int64_t ret_ref = 0;
4260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4263         ret_ref = (uintptr_t)ret_var.inner & ~1;
4264         return ret_ref;
4265 }
4266
4267 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4268 CHECK(!owner->result_ok);
4269         return DecodeError_clone(&*owner->contents.err);
4270 }
4271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4272         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4273         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4274         int64_t ret_ref = 0;
4275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4278         ret_ref = (uintptr_t)ret_var.inner;
4279         if (ret_var.is_owned) {
4280                 ret_ref |= 1;
4281         }
4282         return ret_ref;
4283 }
4284
4285 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4286 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4287 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4288 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4290         LDKCOption_CVec_NetAddressZZ_Some_class =
4291                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4292         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4293         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4294         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4295         LDKCOption_CVec_NetAddressZZ_None_class =
4296                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4297         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4298         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4299         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4300 }
4301 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4302         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4303         switch(obj->tag) {
4304                 case LDKCOption_CVec_NetAddressZZ_Some: {
4305                         LDKCVec_NetAddressZ some_var = obj->some;
4306                         int64_tArray some_arr = NULL;
4307                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4308                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4309                         for (size_t m = 0; m < some_var.datalen; m++) {
4310                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4311                                 some_arr_ptr[m] = some_conv_12_ref;
4312                         }
4313                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4314                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4315                 }
4316                 case LDKCOption_CVec_NetAddressZZ_None: {
4317                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4318                 }
4319                 default: abort();
4320         }
4321 }
4322 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4323 CHECK(owner->result_ok);
4324         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4325 }
4326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4327         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4328         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4329         int64_t ret_ref = 0;
4330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4333         ret_ref = (uintptr_t)ret_var.inner;
4334         if (ret_var.is_owned) {
4335                 ret_ref |= 1;
4336         }
4337         return ret_ref;
4338 }
4339
4340 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4341 CHECK(!owner->result_ok);
4342         return DecodeError_clone(&*owner->contents.err);
4343 }
4344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4345         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4346         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4347         int64_t ret_ref = 0;
4348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4351         ret_ref = (uintptr_t)ret_var.inner;
4352         if (ret_var.is_owned) {
4353                 ret_ref |= 1;
4354         }
4355         return ret_ref;
4356 }
4357
4358 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4359 CHECK(owner->result_ok);
4360         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4361 }
4362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4363         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4364         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4365         int64_t ret_ref = 0;
4366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4369         ret_ref = (uintptr_t)ret_var.inner;
4370         if (ret_var.is_owned) {
4371                 ret_ref |= 1;
4372         }
4373         return ret_ref;
4374 }
4375
4376 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4377 CHECK(!owner->result_ok);
4378         return DecodeError_clone(&*owner->contents.err);
4379 }
4380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4381         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4382         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4383         int64_t ret_ref = 0;
4384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4387         ret_ref = (uintptr_t)ret_var.inner;
4388         if (ret_var.is_owned) {
4389                 ret_ref |= 1;
4390         }
4391         return ret_ref;
4392 }
4393
4394 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4395 CHECK(owner->result_ok);
4396         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4397 }
4398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4399         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4400         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4401         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4402         int64_t ret_ref = (uintptr_t)ret_copy;
4403         return ret_ref;
4404 }
4405
4406 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4407 CHECK(!owner->result_ok);
4408         return DecodeError_clone(&*owner->contents.err);
4409 }
4410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4411         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4412         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4413         int64_t ret_ref = 0;
4414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4417         ret_ref = (uintptr_t)ret_var.inner;
4418         if (ret_var.is_owned) {
4419                 ret_ref |= 1;
4420         }
4421         return ret_ref;
4422 }
4423
4424 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4425         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4426         for (size_t i = 0; i < ret.datalen; i++) {
4427                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4428         }
4429         return ret;
4430 }
4431 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4432         return owner->a;
4433 }
4434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4435         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4436         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4438         return ret_arr;
4439 }
4440
4441 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4442         return owner->b;
4443 }
4444 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4445         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4446         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4447         jobjectArray ret_arr = NULL;
4448         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4449         ;
4450         for (size_t i = 0; i < ret_var.datalen; i++) {
4451                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4452                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4453                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4454         }
4455         
4456         return ret_arr;
4457 }
4458
4459 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4460 CHECK(owner->result_ok);
4461         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4462 }
4463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4464         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4465         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4466         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4467         return ((int64_t)ret_conv);
4468 }
4469
4470 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4471 CHECK(!owner->result_ok);
4472         return *owner->contents.err;
4473 }
4474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4475         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4476         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4477 }
4478
4479 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4480 CHECK(owner->result_ok);
4481         return *owner->contents.result;
4482 }
4483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4484         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4485         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4487         return ret_arr;
4488 }
4489
4490 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4491 CHECK(!owner->result_ok);
4492         return *owner->contents.err;
4493 }
4494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4495         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4496         CResult_SignatureNoneZ_get_err(owner_conv);
4497 }
4498
4499 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4500         return owner->a;
4501 }
4502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4503         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4504         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4506         return ret_arr;
4507 }
4508
4509 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4510         return owner->b;
4511 }
4512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4513         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4514         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4515         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4516         return ret_arr;
4517 }
4518
4519 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4520 CHECK(owner->result_ok);
4521         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4522 }
4523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4524         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4525         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4526         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4527         return ((int64_t)ret_conv);
4528 }
4529
4530 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4531 CHECK(!owner->result_ok);
4532         return *owner->contents.err;
4533 }
4534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4535         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4536         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4537 }
4538
4539 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4540 CHECK(owner->result_ok);
4541         return *owner->contents.result;
4542 }
4543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4544         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4545         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4547         return ret_arr;
4548 }
4549
4550 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4551 CHECK(!owner->result_ok);
4552         return *owner->contents.err;
4553 }
4554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4555         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4556         CResult_SecretKeyNoneZ_get_err(owner_conv);
4557 }
4558
4559 typedef struct LDKBaseSign_JCalls {
4560         atomic_size_t refcnt;
4561         JavaVM *vm;
4562         jweak o;
4563         jmethodID get_per_commitment_point_meth;
4564         jmethodID release_commitment_secret_meth;
4565         jmethodID validate_holder_commitment_meth;
4566         jmethodID channel_keys_id_meth;
4567         jmethodID sign_counterparty_commitment_meth;
4568         jmethodID validate_counterparty_revocation_meth;
4569         jmethodID sign_holder_commitment_and_htlcs_meth;
4570         jmethodID sign_justice_revoked_output_meth;
4571         jmethodID sign_justice_revoked_htlc_meth;
4572         jmethodID sign_counterparty_htlc_transaction_meth;
4573         jmethodID sign_closing_transaction_meth;
4574         jmethodID sign_channel_announcement_meth;
4575         jmethodID ready_channel_meth;
4576 } LDKBaseSign_JCalls;
4577 static void LDKBaseSign_JCalls_free(void* this_arg) {
4578         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4579         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4580                 JNIEnv *env;
4581                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4582                 if (get_jenv_res == JNI_EDETACHED) {
4583                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4584                 } else {
4585                         DO_ASSERT(get_jenv_res == JNI_OK);
4586                 }
4587                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4588                 if (get_jenv_res == JNI_EDETACHED) {
4589                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4590                 }
4591                 FREE(j_calls);
4592         }
4593 }
4594 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4595         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4596         JNIEnv *env;
4597         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4598         if (get_jenv_res == JNI_EDETACHED) {
4599                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4600         } else {
4601                 DO_ASSERT(get_jenv_res == JNI_OK);
4602         }
4603         int64_t idx_conv = idx;
4604         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4605         CHECK(obj != NULL);
4606         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4607         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4608                 (*env)->ExceptionDescribe(env);
4609                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4610         }
4611         LDKPublicKey ret_ref;
4612         CHECK((*env)->GetArrayLength(env, ret) == 33);
4613         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4614         if (get_jenv_res == JNI_EDETACHED) {
4615                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4616         }
4617         return ret_ref;
4618 }
4619 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4620         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4621         JNIEnv *env;
4622         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4623         if (get_jenv_res == JNI_EDETACHED) {
4624                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4625         } else {
4626                 DO_ASSERT(get_jenv_res == JNI_OK);
4627         }
4628         int64_t idx_conv = idx;
4629         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4630         CHECK(obj != NULL);
4631         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4632         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4633                 (*env)->ExceptionDescribe(env);
4634                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4635         }
4636         LDKThirtyTwoBytes ret_ref;
4637         CHECK((*env)->GetArrayLength(env, ret) == 32);
4638         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4639         if (get_jenv_res == JNI_EDETACHED) {
4640                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4641         }
4642         return ret_ref;
4643 }
4644 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4645         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4646         JNIEnv *env;
4647         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4648         if (get_jenv_res == JNI_EDETACHED) {
4649                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4650         } else {
4651                 DO_ASSERT(get_jenv_res == JNI_OK);
4652         }
4653         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4654         int64_t holder_tx_ref = 0;
4655         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4656         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4657         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4658         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4659         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
4660         if (holder_tx_var.is_owned) {
4661                 holder_tx_ref |= 1;
4662         }
4663         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4664         jobjectArray preimages_arr = NULL;
4665         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4666         ;
4667         for (size_t i = 0; i < preimages_var.datalen; i++) {
4668                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4669                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4670                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4671         }
4672         
4673         FREE(preimages_var.data);
4674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4675         CHECK(obj != NULL);
4676         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4677         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4678                 (*env)->ExceptionDescribe(env);
4679                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4680         }
4681         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4682         CHECK_ACCESS(ret_ptr);
4683         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4684         FREE((void*)ret);
4685         if (get_jenv_res == JNI_EDETACHED) {
4686                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4687         }
4688         return ret_conv;
4689 }
4690 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4691         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4692         JNIEnv *env;
4693         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4694         if (get_jenv_res == JNI_EDETACHED) {
4695                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4696         } else {
4697                 DO_ASSERT(get_jenv_res == JNI_OK);
4698         }
4699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4700         CHECK(obj != NULL);
4701         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4702         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4703                 (*env)->ExceptionDescribe(env);
4704                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4705         }
4706         LDKThirtyTwoBytes ret_ref;
4707         CHECK((*env)->GetArrayLength(env, ret) == 32);
4708         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4709         if (get_jenv_res == JNI_EDETACHED) {
4710                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4711         }
4712         return ret_ref;
4713 }
4714 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4715         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4716         JNIEnv *env;
4717         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4718         if (get_jenv_res == JNI_EDETACHED) {
4719                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4720         } else {
4721                 DO_ASSERT(get_jenv_res == JNI_OK);
4722         }
4723         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4724         int64_t commitment_tx_ref = 0;
4725         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4726         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4727         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4728         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4729         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4730         if (commitment_tx_var.is_owned) {
4731                 commitment_tx_ref |= 1;
4732         }
4733         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4734         jobjectArray preimages_arr = NULL;
4735         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4736         ;
4737         for (size_t i = 0; i < preimages_var.datalen; i++) {
4738                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4739                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4740                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4741         }
4742         
4743         FREE(preimages_var.data);
4744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4745         CHECK(obj != NULL);
4746         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4747         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4748                 (*env)->ExceptionDescribe(env);
4749                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4750         }
4751         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4752         CHECK_ACCESS(ret_ptr);
4753         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4754         FREE((void*)ret);
4755         if (get_jenv_res == JNI_EDETACHED) {
4756                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4757         }
4758         return ret_conv;
4759 }
4760 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4761         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4762         JNIEnv *env;
4763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4764         if (get_jenv_res == JNI_EDETACHED) {
4765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4766         } else {
4767                 DO_ASSERT(get_jenv_res == JNI_OK);
4768         }
4769         int64_t idx_conv = idx;
4770         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4771         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4772         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4773         CHECK(obj != NULL);
4774         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4775         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4776                 (*env)->ExceptionDescribe(env);
4777                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4778         }
4779         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4780         CHECK_ACCESS(ret_ptr);
4781         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4782         FREE((void*)ret);
4783         if (get_jenv_res == JNI_EDETACHED) {
4784                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4785         }
4786         return ret_conv;
4787 }
4788 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4789         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4790         JNIEnv *env;
4791         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4792         if (get_jenv_res == JNI_EDETACHED) {
4793                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4794         } else {
4795                 DO_ASSERT(get_jenv_res == JNI_OK);
4796         }
4797         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4798         int64_t commitment_tx_ref = 0;
4799         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4800         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4801         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4802         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4803         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4804         if (commitment_tx_var.is_owned) {
4805                 commitment_tx_ref |= 1;
4806         }
4807         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4808         CHECK(obj != NULL);
4809         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
4810         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4811                 (*env)->ExceptionDescribe(env);
4812                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
4813         }
4814         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4815         CHECK_ACCESS(ret_ptr);
4816         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4817         FREE((void*)ret);
4818         if (get_jenv_res == JNI_EDETACHED) {
4819                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4820         }
4821         return ret_conv;
4822 }
4823 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]) {
4824         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4825         JNIEnv *env;
4826         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4827         if (get_jenv_res == JNI_EDETACHED) {
4828                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4829         } else {
4830                 DO_ASSERT(get_jenv_res == JNI_OK);
4831         }
4832         LDKTransaction justice_tx_var = justice_tx;
4833         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4834         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4835         Transaction_free(justice_tx_var);
4836         int64_t input_conv = input;
4837         int64_t amount_conv = amount;
4838         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4839         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4840         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4841         CHECK(obj != NULL);
4842         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);
4843         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4844                 (*env)->ExceptionDescribe(env);
4845                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
4846         }
4847         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4848         CHECK_ACCESS(ret_ptr);
4849         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4850         FREE((void*)ret);
4851         if (get_jenv_res == JNI_EDETACHED) {
4852                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4853         }
4854         return ret_conv;
4855 }
4856 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) {
4857         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4858         JNIEnv *env;
4859         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4860         if (get_jenv_res == JNI_EDETACHED) {
4861                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4862         } else {
4863                 DO_ASSERT(get_jenv_res == JNI_OK);
4864         }
4865         LDKTransaction justice_tx_var = justice_tx;
4866         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4867         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4868         Transaction_free(justice_tx_var);
4869         int64_t input_conv = input;
4870         int64_t amount_conv = amount;
4871         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4872         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4873         LDKHTLCOutputInCommitment htlc_var = *htlc;
4874         int64_t htlc_ref = 0;
4875         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4876         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4877         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4878         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4879         htlc_ref = (uintptr_t)htlc_var.inner;
4880         if (htlc_var.is_owned) {
4881                 htlc_ref |= 1;
4882         }
4883         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4884         CHECK(obj != NULL);
4885         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);
4886         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4887                 (*env)->ExceptionDescribe(env);
4888                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4889         }
4890         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4891         CHECK_ACCESS(ret_ptr);
4892         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4893         FREE((void*)ret);
4894         if (get_jenv_res == JNI_EDETACHED) {
4895                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4896         }
4897         return ret_conv;
4898 }
4899 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) {
4900         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4901         JNIEnv *env;
4902         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4903         if (get_jenv_res == JNI_EDETACHED) {
4904                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4905         } else {
4906                 DO_ASSERT(get_jenv_res == JNI_OK);
4907         }
4908         LDKTransaction htlc_tx_var = htlc_tx;
4909         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4910         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4911         Transaction_free(htlc_tx_var);
4912         int64_t input_conv = input;
4913         int64_t amount_conv = amount;
4914         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4915         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4916         LDKHTLCOutputInCommitment htlc_var = *htlc;
4917         int64_t htlc_ref = 0;
4918         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4919         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4920         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4921         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4922         htlc_ref = (uintptr_t)htlc_var.inner;
4923         if (htlc_var.is_owned) {
4924                 htlc_ref |= 1;
4925         }
4926         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4927         CHECK(obj != NULL);
4928         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);
4929         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4930                 (*env)->ExceptionDescribe(env);
4931                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4932         }
4933         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4934         CHECK_ACCESS(ret_ptr);
4935         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4936         FREE((void*)ret);
4937         if (get_jenv_res == JNI_EDETACHED) {
4938                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4939         }
4940         return ret_conv;
4941 }
4942 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4943         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4944         JNIEnv *env;
4945         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4946         if (get_jenv_res == JNI_EDETACHED) {
4947                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4948         } else {
4949                 DO_ASSERT(get_jenv_res == JNI_OK);
4950         }
4951         LDKClosingTransaction closing_tx_var = *closing_tx;
4952         int64_t closing_tx_ref = 0;
4953         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4954         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4955         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4956         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4957         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4958         if (closing_tx_var.is_owned) {
4959                 closing_tx_ref |= 1;
4960         }
4961         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4962         CHECK(obj != NULL);
4963         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4964         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4965                 (*env)->ExceptionDescribe(env);
4966                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4967         }
4968         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4969         CHECK_ACCESS(ret_ptr);
4970         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4971         FREE((void*)ret);
4972         if (get_jenv_res == JNI_EDETACHED) {
4973                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4974         }
4975         return ret_conv;
4976 }
4977 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4978         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4979         JNIEnv *env;
4980         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4981         if (get_jenv_res == JNI_EDETACHED) {
4982                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4983         } else {
4984                 DO_ASSERT(get_jenv_res == JNI_OK);
4985         }
4986         LDKUnsignedChannelAnnouncement msg_var = *msg;
4987         int64_t msg_ref = 0;
4988         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4989         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4990         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4992         msg_ref = (uintptr_t)msg_var.inner;
4993         if (msg_var.is_owned) {
4994                 msg_ref |= 1;
4995         }
4996         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4997         CHECK(obj != NULL);
4998         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4999         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5000                 (*env)->ExceptionDescribe(env);
5001                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5002         }
5003         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5004         CHECK_ACCESS(ret_ptr);
5005         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5006         FREE((void*)ret);
5007         if (get_jenv_res == JNI_EDETACHED) {
5008                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5009         }
5010         return ret_conv;
5011 }
5012 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5013         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5014         JNIEnv *env;
5015         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5016         if (get_jenv_res == JNI_EDETACHED) {
5017                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5018         } else {
5019                 DO_ASSERT(get_jenv_res == JNI_OK);
5020         }
5021         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5022         int64_t channel_parameters_ref = 0;
5023         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5024         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5025         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5026         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5027         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
5028         if (channel_parameters_var.is_owned) {
5029                 channel_parameters_ref |= 1;
5030         }
5031         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5032         CHECK(obj != NULL);
5033         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5034         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5035                 (*env)->ExceptionDescribe(env);
5036                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5037         }
5038         if (get_jenv_res == JNI_EDETACHED) {
5039                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5040         }
5041 }
5042 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5043         jclass c = (*env)->GetObjectClass(env, o);
5044         CHECK(c != NULL);
5045         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5046         atomic_init(&calls->refcnt, 1);
5047         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5048         calls->o = (*env)->NewWeakGlobalRef(env, o);
5049         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5050         CHECK(calls->get_per_commitment_point_meth != NULL);
5051         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5052         CHECK(calls->release_commitment_secret_meth != NULL);
5053         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5054         CHECK(calls->validate_holder_commitment_meth != NULL);
5055         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5056         CHECK(calls->channel_keys_id_meth != NULL);
5057         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5058         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5059         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5060         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5061         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5062         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5063         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5064         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5065         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5066         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5067         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5068         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5069         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5070         CHECK(calls->sign_closing_transaction_meth != NULL);
5071         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5072         CHECK(calls->sign_channel_announcement_meth != NULL);
5073         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5074         CHECK(calls->ready_channel_meth != NULL);
5075
5076         LDKChannelPublicKeys pubkeys_conv;
5077         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5078         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5079         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5080
5081         LDKBaseSign ret = {
5082                 .this_arg = (void*) calls,
5083                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5084                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5085                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5086                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5087                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5088                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5089                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5090                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5091                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5092                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5093                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5094                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5095                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5096                 .free = LDKBaseSign_JCalls_free,
5097                 .pubkeys = pubkeys_conv,
5098                 .set_pubkeys = NULL,
5099         };
5100         return ret;
5101 }
5102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5103         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5104         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5105         return (uint64_t)res_ptr;
5106 }
5107 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) {
5108         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5109         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5110         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5111         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5112         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5113         return ret_arr;
5114 }
5115
5116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5117         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5118         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5119         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5120         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5121         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5122         return ret_arr;
5123 }
5124
5125 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) {
5126         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5127         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5128         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5129         LDKHolderCommitmentTransaction holder_tx_conv;
5130         holder_tx_conv.inner = (void*)(holder_tx & (~1));
5131         holder_tx_conv.is_owned = false;
5132         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5133         LDKCVec_PaymentPreimageZ preimages_constr;
5134         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5135         if (preimages_constr.datalen > 0)
5136                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5137         else
5138                 preimages_constr.data = NULL;
5139         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5140                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5141                 LDKThirtyTwoBytes preimages_conv_8_ref;
5142                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5143                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5144                 preimages_constr.data[i] = preimages_conv_8_ref;
5145         }
5146         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5147         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5148         return (int64_t)ret_conv;
5149 }
5150
5151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5152         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5153         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5154         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5155         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5156         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5157         return ret_arr;
5158 }
5159
5160 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) {
5161         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5162         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5163         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5164         LDKCommitmentTransaction commitment_tx_conv;
5165         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5166         commitment_tx_conv.is_owned = false;
5167         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5168         LDKCVec_PaymentPreimageZ preimages_constr;
5169         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5170         if (preimages_constr.datalen > 0)
5171                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5172         else
5173                 preimages_constr.data = NULL;
5174         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5175                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5176                 LDKThirtyTwoBytes preimages_conv_8_ref;
5177                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5178                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5179                 preimages_constr.data[i] = preimages_conv_8_ref;
5180         }
5181         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5182         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5183         return (int64_t)ret_conv;
5184 }
5185
5186 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) {
5187         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5188         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5189         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5190         unsigned char secret_arr[32];
5191         CHECK((*env)->GetArrayLength(env, secret) == 32);
5192         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5193         unsigned char (*secret_ref)[32] = &secret_arr;
5194         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5195         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5196         return (int64_t)ret_conv;
5197 }
5198
5199 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) {
5200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5202         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5203         LDKHolderCommitmentTransaction commitment_tx_conv;
5204         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5205         commitment_tx_conv.is_owned = false;
5206         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5207         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5208         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5209         return (int64_t)ret_conv;
5210 }
5211
5212 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) {
5213         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5214         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5215         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5216         LDKTransaction justice_tx_ref;
5217         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5218         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5219         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5220         justice_tx_ref.data_is_owned = true;
5221         unsigned char per_commitment_key_arr[32];
5222         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5223         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5224         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5225         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5226         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5227         return (int64_t)ret_conv;
5228 }
5229
5230 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) {
5231         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5232         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5233         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5234         LDKTransaction justice_tx_ref;
5235         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5236         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5237         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5238         justice_tx_ref.data_is_owned = true;
5239         unsigned char per_commitment_key_arr[32];
5240         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5241         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5242         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5243         LDKHTLCOutputInCommitment htlc_conv;
5244         htlc_conv.inner = (void*)(htlc & (~1));
5245         htlc_conv.is_owned = false;
5246         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5247         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5248         *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);
5249         return (int64_t)ret_conv;
5250 }
5251
5252 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) {
5253         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5254         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5255         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5256         LDKTransaction htlc_tx_ref;
5257         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5258         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5259         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5260         htlc_tx_ref.data_is_owned = true;
5261         LDKPublicKey per_commitment_point_ref;
5262         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5263         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5264         LDKHTLCOutputInCommitment htlc_conv;
5265         htlc_conv.inner = (void*)(htlc & (~1));
5266         htlc_conv.is_owned = false;
5267         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5268         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5269         *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);
5270         return (int64_t)ret_conv;
5271 }
5272
5273 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) {
5274         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5275         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5276         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5277         LDKClosingTransaction closing_tx_conv;
5278         closing_tx_conv.inner = (void*)(closing_tx & (~1));
5279         closing_tx_conv.is_owned = false;
5280         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5281         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5282         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5283         return (int64_t)ret_conv;
5284 }
5285
5286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5287         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5288         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5289         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5290         LDKUnsignedChannelAnnouncement msg_conv;
5291         msg_conv.inner = (void*)(msg & (~1));
5292         msg_conv.is_owned = false;
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5294         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5295         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5296         return (int64_t)ret_conv;
5297 }
5298
5299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5300         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5301         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5302         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5303         LDKChannelTransactionParameters channel_parameters_conv;
5304         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
5305         channel_parameters_conv.is_owned = false;
5306         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5307         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5308 }
5309
5310 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5311         if (this_arg->set_pubkeys != NULL)
5312                 this_arg->set_pubkeys(this_arg);
5313         return this_arg->pubkeys;
5314 }
5315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5316         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5317         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5318         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5319         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5320         int64_t ret_ref = 0;
5321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5324         ret_ref = (uintptr_t)ret_var.inner;
5325         if (ret_var.is_owned) {
5326                 ret_ref |= 1;
5327         }
5328         return ret_ref;
5329 }
5330
5331 typedef struct LDKSign_JCalls {
5332         atomic_size_t refcnt;
5333         JavaVM *vm;
5334         jweak o;
5335         LDKBaseSign_JCalls* BaseSign;
5336         jmethodID write_meth;
5337 } LDKSign_JCalls;
5338 static void LDKSign_JCalls_free(void* this_arg) {
5339         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5340         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5341                 JNIEnv *env;
5342                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5343                 if (get_jenv_res == JNI_EDETACHED) {
5344                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5345                 } else {
5346                         DO_ASSERT(get_jenv_res == JNI_OK);
5347                 }
5348                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5349                 if (get_jenv_res == JNI_EDETACHED) {
5350                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5351                 }
5352                 FREE(j_calls);
5353         }
5354 }
5355 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5356         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5357         JNIEnv *env;
5358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5359         if (get_jenv_res == JNI_EDETACHED) {
5360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5361         } else {
5362                 DO_ASSERT(get_jenv_res == JNI_OK);
5363         }
5364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5365         CHECK(obj != NULL);
5366         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5367         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5368                 (*env)->ExceptionDescribe(env);
5369                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5370         }
5371         LDKCVec_u8Z ret_ref;
5372         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5373         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5374         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5375         if (get_jenv_res == JNI_EDETACHED) {
5376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5377         }
5378         return ret_ref;
5379 }
5380 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5381         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5382         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5383         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5384 }
5385 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5386         jclass c = (*env)->GetObjectClass(env, o);
5387         CHECK(c != NULL);
5388         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5389         atomic_init(&calls->refcnt, 1);
5390         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5391         calls->o = (*env)->NewWeakGlobalRef(env, o);
5392         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5393         CHECK(calls->write_meth != NULL);
5394
5395         LDKChannelPublicKeys pubkeys_conv;
5396         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5397         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5398         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5399
5400         LDKSign ret = {
5401                 .this_arg = (void*) calls,
5402                 .write = write_LDKSign_jcall,
5403                 .cloned = LDKSign_JCalls_cloned,
5404                 .free = LDKSign_JCalls_free,
5405                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5406         };
5407         calls->BaseSign = ret.BaseSign.this_arg;
5408         return ret;
5409 }
5410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5411         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5412         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5413         return (uint64_t)res_ptr;
5414 }
5415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5416         LDKSign *inp = (LDKSign *)(arg & ~1);
5417         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
5418         DO_ASSERT((res_ptr & 1) == 0);
5419         return (int64_t)(res_ptr | 1);
5420 }
5421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5422         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5423         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5424         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5425         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5428         CVec_u8Z_free(ret_var);
5429         return ret_arr;
5430 }
5431
5432 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5433 CHECK(owner->result_ok);
5434         return Sign_clone(&*owner->contents.result);
5435 }
5436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5437         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5438         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5439         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5440         return (int64_t)ret_ret;
5441 }
5442
5443 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5444 CHECK(!owner->result_ok);
5445         return DecodeError_clone(&*owner->contents.err);
5446 }
5447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5448         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5449         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5450         int64_t ret_ref = 0;
5451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5454         ret_ref = (uintptr_t)ret_var.inner;
5455         if (ret_var.is_owned) {
5456                 ret_ref |= 1;
5457         }
5458         return ret_ref;
5459 }
5460
5461 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5462 CHECK(owner->result_ok);
5463         return *owner->contents.result;
5464 }
5465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5466         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5467         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5468         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5469         return ret_arr;
5470 }
5471
5472 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5473 CHECK(!owner->result_ok);
5474         return *owner->contents.err;
5475 }
5476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5477         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5478         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5479 }
5480
5481 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5482         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5483         for (size_t i = 0; i < ret.datalen; i++) {
5484                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5485         }
5486         return ret;
5487 }
5488 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5489 CHECK(owner->result_ok);
5490         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5491 }
5492 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5493         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5494         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5495         jobjectArray ret_arr = NULL;
5496         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5497         ;
5498         for (size_t i = 0; i < ret_var.datalen; i++) {
5499                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5500                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5501                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5502                 CVec_u8Z_free(ret_conv_8_var);
5503                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5504         }
5505         
5506         FREE(ret_var.data);
5507         return ret_arr;
5508 }
5509
5510 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5511 CHECK(!owner->result_ok);
5512         return *owner->contents.err;
5513 }
5514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5515         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5516         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5517 }
5518
5519 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5520 CHECK(owner->result_ok);
5521         return InMemorySigner_clone(&*owner->contents.result);
5522 }
5523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5524         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5525         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5526         int64_t ret_ref = 0;
5527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5530         ret_ref = (uintptr_t)ret_var.inner;
5531         if (ret_var.is_owned) {
5532                 ret_ref |= 1;
5533         }
5534         return ret_ref;
5535 }
5536
5537 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5538 CHECK(!owner->result_ok);
5539         return DecodeError_clone(&*owner->contents.err);
5540 }
5541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5542         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5543         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5544         int64_t ret_ref = 0;
5545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5548         ret_ref = (uintptr_t)ret_var.inner;
5549         if (ret_var.is_owned) {
5550                 ret_ref |= 1;
5551         }
5552         return ret_ref;
5553 }
5554
5555 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5556         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5557         for (size_t i = 0; i < ret.datalen; i++) {
5558                 ret.data[i] = TxOut_clone(&orig->data[i]);
5559         }
5560         return ret;
5561 }
5562 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5563 CHECK(owner->result_ok);
5564         return *owner->contents.result;
5565 }
5566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5567         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5568         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5569         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5570         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5571         return ret_arr;
5572 }
5573
5574 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5575 CHECK(!owner->result_ok);
5576         return *owner->contents.err;
5577 }
5578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5579         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5580         CResult_TransactionNoneZ_get_err(owner_conv);
5581 }
5582
5583 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5584         return ThirtyTwoBytes_clone(&owner->a);
5585 }
5586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5587         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5588         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5590         return ret_arr;
5591 }
5592
5593 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5594         return ChannelMonitor_clone(&owner->b);
5595 }
5596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5597         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5598         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5599         int64_t ret_ref = 0;
5600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5603         ret_ref = (uintptr_t)ret_var.inner;
5604         if (ret_var.is_owned) {
5605                 ret_ref |= 1;
5606         }
5607         return ret_ref;
5608 }
5609
5610 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5611         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5612         for (size_t i = 0; i < ret.datalen; i++) {
5613                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5614         }
5615         return ret;
5616 }
5617 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5618 CHECK(owner->result_ok);
5619         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5620 }
5621 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5622         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5623         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5624         int64_tArray ret_arr = NULL;
5625         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5626         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5627         for (size_t j = 0; j < ret_var.datalen; j++) {
5628                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5629                 *ret_conv_35_conv = ret_var.data[j];
5630                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
5631         }
5632         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5633         FREE(ret_var.data);
5634         return ret_arr;
5635 }
5636
5637 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5638 CHECK(!owner->result_ok);
5639         return *owner->contents.err;
5640 }
5641 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5642         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5643         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5644         return ret_conv;
5645 }
5646
5647 static jclass LDKCOption_u16Z_Some_class = NULL;
5648 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5649 static jclass LDKCOption_u16Z_None_class = NULL;
5650 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5652         LDKCOption_u16Z_Some_class =
5653                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5654         CHECK(LDKCOption_u16Z_Some_class != NULL);
5655         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5656         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5657         LDKCOption_u16Z_None_class =
5658                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5659         CHECK(LDKCOption_u16Z_None_class != NULL);
5660         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5661         CHECK(LDKCOption_u16Z_None_meth != NULL);
5662 }
5663 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5664         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5665         switch(obj->tag) {
5666                 case LDKCOption_u16Z_Some: {
5667                         int16_t some_conv = obj->some;
5668                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5669                 }
5670                 case LDKCOption_u16Z_None: {
5671                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5672                 }
5673                 default: abort();
5674         }
5675 }
5676 static jclass LDKAPIError_APIMisuseError_class = NULL;
5677 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5678 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5679 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5680 static jclass LDKAPIError_RouteError_class = NULL;
5681 static jmethodID LDKAPIError_RouteError_meth = NULL;
5682 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5683 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5684 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5685 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5686 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5687 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5689         LDKAPIError_APIMisuseError_class =
5690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5691         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5692         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5693         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5694         LDKAPIError_FeeRateTooHigh_class =
5695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5696         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5697         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5698         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5699         LDKAPIError_RouteError_class =
5700                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5701         CHECK(LDKAPIError_RouteError_class != NULL);
5702         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5703         CHECK(LDKAPIError_RouteError_meth != NULL);
5704         LDKAPIError_ChannelUnavailable_class =
5705                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5706         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5707         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5708         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5709         LDKAPIError_MonitorUpdateFailed_class =
5710                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5711         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5712         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5713         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5714         LDKAPIError_IncompatibleShutdownScript_class =
5715                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5716         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5717         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5718         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5719 }
5720 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5721         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5722         switch(obj->tag) {
5723                 case LDKAPIError_APIMisuseError: {
5724                         LDKStr err_str = obj->api_misuse_error.err;
5725                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5726                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5727                 }
5728                 case LDKAPIError_FeeRateTooHigh: {
5729                         LDKStr err_str = obj->fee_rate_too_high.err;
5730                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5731                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5732                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5733                 }
5734                 case LDKAPIError_RouteError: {
5735                         LDKStr err_str = obj->route_error.err;
5736                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5737                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5738                 }
5739                 case LDKAPIError_ChannelUnavailable: {
5740                         LDKStr err_str = obj->channel_unavailable.err;
5741                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5742                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5743                 }
5744                 case LDKAPIError_MonitorUpdateFailed: {
5745                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5746                 }
5747                 case LDKAPIError_IncompatibleShutdownScript: {
5748                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5749                         int64_t script_ref = 0;
5750                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5751                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5752                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5753                         script_ref = (uintptr_t)script_var.inner & ~1;
5754                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5755                 }
5756                 default: abort();
5757         }
5758 }
5759 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5760 CHECK(owner->result_ok);
5761         return *owner->contents.result;
5762 }
5763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5764         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5765         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5766 }
5767
5768 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5769 CHECK(!owner->result_ok);
5770         return APIError_clone(&*owner->contents.err);
5771 }
5772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5773         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5774         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5775         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5776         int64_t ret_ref = (uintptr_t)ret_copy;
5777         return ret_ref;
5778 }
5779
5780 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5781         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5782         for (size_t i = 0; i < ret.datalen; i++) {
5783                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5784         }
5785         return ret;
5786 }
5787 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5788         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5789         for (size_t i = 0; i < ret.datalen; i++) {
5790                 ret.data[i] = APIError_clone(&orig->data[i]);
5791         }
5792         return ret;
5793 }
5794 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5795 CHECK(owner->result_ok);
5796         return ThirtyTwoBytes_clone(&*owner->contents.result);
5797 }
5798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5799         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5800         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5801         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
5802         return ret_arr;
5803 }
5804
5805 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5806 CHECK(!owner->result_ok);
5807         return APIError_clone(&*owner->contents.err);
5808 }
5809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5810         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5811         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5812         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5813         int64_t ret_ref = (uintptr_t)ret_copy;
5814         return ret_ref;
5815 }
5816
5817 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
5818 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
5819 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
5820 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
5821 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
5822 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
5823 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
5824 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
5825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
5826         LDKPaymentSendFailure_ParameterError_class =
5827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
5828         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
5829         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
5830         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
5831         LDKPaymentSendFailure_PathParameterError_class =
5832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
5833         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
5834         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
5835         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
5836         LDKPaymentSendFailure_AllFailedRetrySafe_class =
5837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
5838         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
5839         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
5840         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
5841         LDKPaymentSendFailure_PartialFailure_class =
5842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
5843         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
5844         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
5845         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
5846 }
5847 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5848         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5849         switch(obj->tag) {
5850                 case LDKPaymentSendFailure_ParameterError: {
5851                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5852                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
5853                 }
5854                 case LDKPaymentSendFailure_PathParameterError: {
5855                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5856                         int64_tArray path_parameter_error_arr = NULL;
5857                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
5858                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
5859                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5860                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5861                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5862                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5863                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
5864                         }
5865                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
5866                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
5867                 }
5868                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
5869                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5870                         int64_tArray all_failed_retry_safe_arr = NULL;
5871                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5872                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5873                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5874                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5875                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5876                         }
5877                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5878                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5879                 }
5880                 case LDKPaymentSendFailure_PartialFailure: {
5881                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5882                         int64_tArray results_arr = NULL;
5883                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5884                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5885                         for (size_t w = 0; w < results_var.datalen; w++) {
5886                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5887                                 *results_conv_22_conv = results_var.data[w];
5888                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5889                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
5890                         }
5891                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5892                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5893                         int64_t failed_paths_retry_ref = 0;
5894                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
5895                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5896                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5897                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5898                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
5899                         }
5900                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5901                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5902                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5903                 }
5904                 default: abort();
5905         }
5906 }
5907 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5908 CHECK(owner->result_ok);
5909         return ThirtyTwoBytes_clone(&*owner->contents.result);
5910 }
5911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5912         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5913         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5915         return ret_arr;
5916 }
5917
5918 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5919 CHECK(!owner->result_ok);
5920         return PaymentSendFailure_clone(&*owner->contents.err);
5921 }
5922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5923         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5924         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5925         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5926         int64_t ret_ref = (uintptr_t)ret_copy;
5927         return ret_ref;
5928 }
5929
5930 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5931 CHECK(owner->result_ok);
5932         return *owner->contents.result;
5933 }
5934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5935         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5936         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5937 }
5938
5939 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5940 CHECK(!owner->result_ok);
5941         return PaymentSendFailure_clone(&*owner->contents.err);
5942 }
5943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5944         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5945         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5946         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5947         int64_t ret_ref = (uintptr_t)ret_copy;
5948         return ret_ref;
5949 }
5950
5951 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5952         return ThirtyTwoBytes_clone(&owner->a);
5953 }
5954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5955         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5958         return ret_arr;
5959 }
5960
5961 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5962         return ThirtyTwoBytes_clone(&owner->b);
5963 }
5964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5965         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5966         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5967         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5968         return ret_arr;
5969 }
5970
5971 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5972 CHECK(owner->result_ok);
5973         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5974 }
5975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5976         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5977         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5978         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5979         return ((int64_t)ret_conv);
5980 }
5981
5982 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5983 CHECK(!owner->result_ok);
5984         return PaymentSendFailure_clone(&*owner->contents.err);
5985 }
5986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5987         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5988         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5989         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5990         int64_t ret_ref = (uintptr_t)ret_copy;
5991         return ret_ref;
5992 }
5993
5994 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
5995         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
5996         for (size_t i = 0; i < ret.datalen; i++) {
5997                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5998         }
5999         return ret;
6000 }
6001 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6002         return ThirtyTwoBytes_clone(&owner->a);
6003 }
6004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6005         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6006         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6008         return ret_arr;
6009 }
6010
6011 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6012         return ThirtyTwoBytes_clone(&owner->b);
6013 }
6014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6015         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6016         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6018         return ret_arr;
6019 }
6020
6021 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6022 CHECK(owner->result_ok);
6023         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6024 }
6025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6026         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6027         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6028         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6029         return ((int64_t)ret_conv);
6030 }
6031
6032 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6033 CHECK(!owner->result_ok);
6034         return *owner->contents.err;
6035 }
6036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6037         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6038         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6039 }
6040
6041 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6042 CHECK(owner->result_ok);
6043         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6044 }
6045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6046         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6047         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6048         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6049         return ((int64_t)ret_conv);
6050 }
6051
6052 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6053 CHECK(!owner->result_ok);
6054         return APIError_clone(&*owner->contents.err);
6055 }
6056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6057         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6058         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6059         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6060         int64_t ret_ref = (uintptr_t)ret_copy;
6061         return ret_ref;
6062 }
6063
6064 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6065 CHECK(owner->result_ok);
6066         return ThirtyTwoBytes_clone(&*owner->contents.result);
6067 }
6068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6069         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6070         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6072         return ret_arr;
6073 }
6074
6075 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6076 CHECK(!owner->result_ok);
6077         return *owner->contents.err;
6078 }
6079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6080         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6081         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6082 }
6083
6084 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6085 CHECK(owner->result_ok);
6086         return ThirtyTwoBytes_clone(&*owner->contents.result);
6087 }
6088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6089         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6090         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6091         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6092         return ret_arr;
6093 }
6094
6095 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6096 CHECK(!owner->result_ok);
6097         return APIError_clone(&*owner->contents.err);
6098 }
6099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6100         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6101         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6102         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6103         int64_t ret_ref = (uintptr_t)ret_copy;
6104         return ret_ref;
6105 }
6106
6107 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6108 CHECK(owner->result_ok);
6109         return ThirtyTwoBytes_clone(&*owner->contents.result);
6110 }
6111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6112         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6113         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6114         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6115         return ret_arr;
6116 }
6117
6118 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6119 CHECK(!owner->result_ok);
6120         return APIError_clone(&*owner->contents.err);
6121 }
6122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6123         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6124         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6125         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6126         int64_t ret_ref = (uintptr_t)ret_copy;
6127         return ret_ref;
6128 }
6129
6130 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6131 CHECK(owner->result_ok);
6132         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
6133 }
6134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6135         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6136         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6137         int64_t ret_ref = 0;
6138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6141         ret_ref = (uintptr_t)ret_var.inner;
6142         if (ret_var.is_owned) {
6143                 ret_ref |= 1;
6144         }
6145         return ret_ref;
6146 }
6147
6148 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6149 CHECK(!owner->result_ok);
6150         return DecodeError_clone(&*owner->contents.err);
6151 }
6152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6153         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6154         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6155         int64_t ret_ref = 0;
6156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6159         ret_ref = (uintptr_t)ret_var.inner;
6160         if (ret_var.is_owned) {
6161                 ret_ref |= 1;
6162         }
6163         return ret_ref;
6164 }
6165
6166 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6167 CHECK(owner->result_ok);
6168         return ChannelCounterparty_clone(&*owner->contents.result);
6169 }
6170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6171         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6172         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6173         int64_t ret_ref = 0;
6174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6177         ret_ref = (uintptr_t)ret_var.inner;
6178         if (ret_var.is_owned) {
6179                 ret_ref |= 1;
6180         }
6181         return ret_ref;
6182 }
6183
6184 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6185 CHECK(!owner->result_ok);
6186         return DecodeError_clone(&*owner->contents.err);
6187 }
6188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6189         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6190         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6191         int64_t ret_ref = 0;
6192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6195         ret_ref = (uintptr_t)ret_var.inner;
6196         if (ret_var.is_owned) {
6197                 ret_ref |= 1;
6198         }
6199         return ret_ref;
6200 }
6201
6202 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6203 CHECK(owner->result_ok);
6204         return ChannelDetails_clone(&*owner->contents.result);
6205 }
6206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6207         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6208         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6209         int64_t ret_ref = 0;
6210         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6211         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6213         ret_ref = (uintptr_t)ret_var.inner;
6214         if (ret_var.is_owned) {
6215                 ret_ref |= 1;
6216         }
6217         return ret_ref;
6218 }
6219
6220 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6221 CHECK(!owner->result_ok);
6222         return DecodeError_clone(&*owner->contents.err);
6223 }
6224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6225         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6226         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6227         int64_t ret_ref = 0;
6228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6231         ret_ref = (uintptr_t)ret_var.inner;
6232         if (ret_var.is_owned) {
6233                 ret_ref |= 1;
6234         }
6235         return ret_ref;
6236 }
6237
6238 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6239 CHECK(owner->result_ok);
6240         return PhantomRouteHints_clone(&*owner->contents.result);
6241 }
6242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6243         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6244         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6245         int64_t ret_ref = 0;
6246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6249         ret_ref = (uintptr_t)ret_var.inner;
6250         if (ret_var.is_owned) {
6251                 ret_ref |= 1;
6252         }
6253         return ret_ref;
6254 }
6255
6256 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6257 CHECK(!owner->result_ok);
6258         return DecodeError_clone(&*owner->contents.err);
6259 }
6260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6261         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6262         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6263         int64_t ret_ref = 0;
6264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6267         ret_ref = (uintptr_t)ret_var.inner;
6268         if (ret_var.is_owned) {
6269                 ret_ref |= 1;
6270         }
6271         return ret_ref;
6272 }
6273
6274 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6275         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6276         for (size_t i = 0; i < ret.datalen; i++) {
6277                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6278         }
6279         return ret;
6280 }
6281 typedef struct LDKWatch_JCalls {
6282         atomic_size_t refcnt;
6283         JavaVM *vm;
6284         jweak o;
6285         jmethodID watch_channel_meth;
6286         jmethodID update_channel_meth;
6287         jmethodID release_pending_monitor_events_meth;
6288 } LDKWatch_JCalls;
6289 static void LDKWatch_JCalls_free(void* this_arg) {
6290         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6291         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6292                 JNIEnv *env;
6293                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6294                 if (get_jenv_res == JNI_EDETACHED) {
6295                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6296                 } else {
6297                         DO_ASSERT(get_jenv_res == JNI_OK);
6298                 }
6299                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6300                 if (get_jenv_res == JNI_EDETACHED) {
6301                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6302                 }
6303                 FREE(j_calls);
6304         }
6305 }
6306 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6307         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6308         JNIEnv *env;
6309         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6310         if (get_jenv_res == JNI_EDETACHED) {
6311                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6312         } else {
6313                 DO_ASSERT(get_jenv_res == JNI_OK);
6314         }
6315         LDKOutPoint funding_txo_var = funding_txo;
6316         int64_t funding_txo_ref = 0;
6317         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6318         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6319         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6320         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6321         if (funding_txo_var.is_owned) {
6322                 funding_txo_ref |= 1;
6323         }
6324         LDKChannelMonitor monitor_var = monitor;
6325         int64_t monitor_ref = 0;
6326         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6327         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6328         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6329         monitor_ref = (uintptr_t)monitor_var.inner;
6330         if (monitor_var.is_owned) {
6331                 monitor_ref |= 1;
6332         }
6333         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6334         CHECK(obj != NULL);
6335         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6336         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6337                 (*env)->ExceptionDescribe(env);
6338                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6339         }
6340         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6341         CHECK_ACCESS(ret_ptr);
6342         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6343         FREE((void*)ret);
6344         if (get_jenv_res == JNI_EDETACHED) {
6345                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6346         }
6347         return ret_conv;
6348 }
6349 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6350         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6351         JNIEnv *env;
6352         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6353         if (get_jenv_res == JNI_EDETACHED) {
6354                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6355         } else {
6356                 DO_ASSERT(get_jenv_res == JNI_OK);
6357         }
6358         LDKOutPoint funding_txo_var = funding_txo;
6359         int64_t funding_txo_ref = 0;
6360         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6361         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6362         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6363         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6364         if (funding_txo_var.is_owned) {
6365                 funding_txo_ref |= 1;
6366         }
6367         LDKChannelMonitorUpdate update_var = update;
6368         int64_t update_ref = 0;
6369         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6370         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6371         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6372         update_ref = (uintptr_t)update_var.inner;
6373         if (update_var.is_owned) {
6374                 update_ref |= 1;
6375         }
6376         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6377         CHECK(obj != NULL);
6378         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6379         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6380                 (*env)->ExceptionDescribe(env);
6381                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6382         }
6383         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6384         CHECK_ACCESS(ret_ptr);
6385         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6386         FREE((void*)ret);
6387         if (get_jenv_res == JNI_EDETACHED) {
6388                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6389         }
6390         return ret_conv;
6391 }
6392 LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6393         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6394         JNIEnv *env;
6395         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6396         if (get_jenv_res == JNI_EDETACHED) {
6397                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6398         } else {
6399                 DO_ASSERT(get_jenv_res == JNI_OK);
6400         }
6401         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6402         CHECK(obj != NULL);
6403         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6404         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6405                 (*env)->ExceptionDescribe(env);
6406                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6407         }
6408         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_constr;
6409         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6410         if (ret_constr.datalen > 0)
6411                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
6412         else
6413                 ret_constr.data = NULL;
6414         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6415         for (size_t m = 0; m < ret_constr.datalen; m++) {
6416                 int64_t ret_conv_38 = ret_vals[m];
6417                 void* ret_conv_38_ptr = (void*)(((uintptr_t)ret_conv_38) & ~1);
6418                 CHECK_ACCESS(ret_conv_38_ptr);
6419                 LDKC2Tuple_OutPointCVec_MonitorEventZZ ret_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(ret_conv_38_ptr);
6420                 FREE((void*)ret_conv_38);
6421                 ret_constr.data[m] = ret_conv_38_conv;
6422         }
6423         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6424         if (get_jenv_res == JNI_EDETACHED) {
6425                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6426         }
6427         return ret_constr;
6428 }
6429 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6430         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6431         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6432 }
6433 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6434         jclass c = (*env)->GetObjectClass(env, o);
6435         CHECK(c != NULL);
6436         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6437         atomic_init(&calls->refcnt, 1);
6438         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6439         calls->o = (*env)->NewWeakGlobalRef(env, o);
6440         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6441         CHECK(calls->watch_channel_meth != NULL);
6442         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6443         CHECK(calls->update_channel_meth != NULL);
6444         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6445         CHECK(calls->release_pending_monitor_events_meth != NULL);
6446
6447         LDKWatch ret = {
6448                 .this_arg = (void*) calls,
6449                 .watch_channel = watch_channel_LDKWatch_jcall,
6450                 .update_channel = update_channel_LDKWatch_jcall,
6451                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6452                 .free = LDKWatch_JCalls_free,
6453         };
6454         return ret;
6455 }
6456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6457         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6458         *res_ptr = LDKWatch_init(env, clz, o);
6459         return (uint64_t)res_ptr;
6460 }
6461 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) {
6462         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6463         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6464         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6465         LDKOutPoint funding_txo_conv;
6466         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6467         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6468         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6469         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6470         LDKChannelMonitor monitor_conv;
6471         monitor_conv.inner = (void*)(monitor & (~1));
6472         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6473         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6474         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6475         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6476         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6477         return (int64_t)ret_conv;
6478 }
6479
6480 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) {
6481         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6482         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6483         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6484         LDKOutPoint funding_txo_conv;
6485         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6486         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6487         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6488         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6489         LDKChannelMonitorUpdate update_conv;
6490         update_conv.inner = (void*)(update & (~1));
6491         update_conv.is_owned = (update & 1) || (update == 0);
6492         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6493         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6494         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6495         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6496         return (int64_t)ret_conv;
6497 }
6498
6499 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6500         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6501         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6502         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6503         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6504         int64_tArray ret_arr = NULL;
6505         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6506         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6507         for (size_t m = 0; m < ret_var.datalen; m++) {
6508                 LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv_38_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
6509                 *ret_conv_38_conv = ret_var.data[m];
6510                 ret_arr_ptr[m] = ((int64_t)ret_conv_38_conv);
6511         }
6512         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6513         FREE(ret_var.data);
6514         return ret_arr;
6515 }
6516
6517 typedef struct LDKBroadcasterInterface_JCalls {
6518         atomic_size_t refcnt;
6519         JavaVM *vm;
6520         jweak o;
6521         jmethodID broadcast_transaction_meth;
6522 } LDKBroadcasterInterface_JCalls;
6523 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6524         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6525         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6526                 JNIEnv *env;
6527                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6528                 if (get_jenv_res == JNI_EDETACHED) {
6529                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6530                 } else {
6531                         DO_ASSERT(get_jenv_res == JNI_OK);
6532                 }
6533                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6534                 if (get_jenv_res == JNI_EDETACHED) {
6535                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6536                 }
6537                 FREE(j_calls);
6538         }
6539 }
6540 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6541         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6542         JNIEnv *env;
6543         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6544         if (get_jenv_res == JNI_EDETACHED) {
6545                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6546         } else {
6547                 DO_ASSERT(get_jenv_res == JNI_OK);
6548         }
6549         LDKTransaction tx_var = tx;
6550         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6551         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6552         Transaction_free(tx_var);
6553         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6554         CHECK(obj != NULL);
6555         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6556         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6557                 (*env)->ExceptionDescribe(env);
6558                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6559         }
6560         if (get_jenv_res == JNI_EDETACHED) {
6561                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6562         }
6563 }
6564 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6565         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6566         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6567 }
6568 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6569         jclass c = (*env)->GetObjectClass(env, o);
6570         CHECK(c != NULL);
6571         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6572         atomic_init(&calls->refcnt, 1);
6573         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6574         calls->o = (*env)->NewWeakGlobalRef(env, o);
6575         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6576         CHECK(calls->broadcast_transaction_meth != NULL);
6577
6578         LDKBroadcasterInterface ret = {
6579                 .this_arg = (void*) calls,
6580                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6581                 .free = LDKBroadcasterInterface_JCalls_free,
6582         };
6583         return ret;
6584 }
6585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6586         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6587         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6588         return (uint64_t)res_ptr;
6589 }
6590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6591         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6592         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6593         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6594         LDKTransaction tx_ref;
6595         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6596         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6597         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6598         tx_ref.data_is_owned = true;
6599         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6600 }
6601
6602 typedef struct LDKKeysInterface_JCalls {
6603         atomic_size_t refcnt;
6604         JavaVM *vm;
6605         jweak o;
6606         jmethodID get_node_secret_meth;
6607         jmethodID get_destination_script_meth;
6608         jmethodID get_shutdown_scriptpubkey_meth;
6609         jmethodID get_channel_signer_meth;
6610         jmethodID get_secure_random_bytes_meth;
6611         jmethodID read_chan_signer_meth;
6612         jmethodID sign_invoice_meth;
6613         jmethodID get_inbound_payment_key_material_meth;
6614 } LDKKeysInterface_JCalls;
6615 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6616         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6617         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6618                 JNIEnv *env;
6619                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6620                 if (get_jenv_res == JNI_EDETACHED) {
6621                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6622                 } else {
6623                         DO_ASSERT(get_jenv_res == JNI_OK);
6624                 }
6625                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6626                 if (get_jenv_res == JNI_EDETACHED) {
6627                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6628                 }
6629                 FREE(j_calls);
6630         }
6631 }
6632 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6633         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6634         JNIEnv *env;
6635         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6636         if (get_jenv_res == JNI_EDETACHED) {
6637                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6638         } else {
6639                 DO_ASSERT(get_jenv_res == JNI_OK);
6640         }
6641         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6642         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6643         CHECK(obj != NULL);
6644         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6645         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6646                 (*env)->ExceptionDescribe(env);
6647                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6648         }
6649         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6650         CHECK_ACCESS(ret_ptr);
6651         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6652         FREE((void*)ret);
6653         if (get_jenv_res == JNI_EDETACHED) {
6654                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6655         }
6656         return ret_conv;
6657 }
6658 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6659         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6660         JNIEnv *env;
6661         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6662         if (get_jenv_res == JNI_EDETACHED) {
6663                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6664         } else {
6665                 DO_ASSERT(get_jenv_res == JNI_OK);
6666         }
6667         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6668         CHECK(obj != NULL);
6669         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6670         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6671                 (*env)->ExceptionDescribe(env);
6672                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6673         }
6674         LDKCVec_u8Z ret_ref;
6675         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6676         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6677         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6678         if (get_jenv_res == JNI_EDETACHED) {
6679                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6680         }
6681         return ret_ref;
6682 }
6683 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6684         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6685         JNIEnv *env;
6686         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6687         if (get_jenv_res == JNI_EDETACHED) {
6688                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6689         } else {
6690                 DO_ASSERT(get_jenv_res == JNI_OK);
6691         }
6692         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6693         CHECK(obj != NULL);
6694         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6695         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6696                 (*env)->ExceptionDescribe(env);
6697                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6698         }
6699         LDKShutdownScript ret_conv;
6700         ret_conv.inner = (void*)(ret & (~1));
6701         ret_conv.is_owned = (ret & 1) || (ret == 0);
6702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6703         if (get_jenv_res == JNI_EDETACHED) {
6704                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6705         }
6706         return ret_conv;
6707 }
6708 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6709         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6710         JNIEnv *env;
6711         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6712         if (get_jenv_res == JNI_EDETACHED) {
6713                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6714         } else {
6715                 DO_ASSERT(get_jenv_res == JNI_OK);
6716         }
6717         jboolean inbound_conv = inbound;
6718         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6719         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6720         CHECK(obj != NULL);
6721         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6722         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6723                 (*env)->ExceptionDescribe(env);
6724                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6725         }
6726         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6727         CHECK_ACCESS(ret_ptr);
6728         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6729         FREE((void*)ret);
6730         if (get_jenv_res == JNI_EDETACHED) {
6731                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6732         }
6733         return ret_conv;
6734 }
6735 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6736         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6737         JNIEnv *env;
6738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6739         if (get_jenv_res == JNI_EDETACHED) {
6740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6741         } else {
6742                 DO_ASSERT(get_jenv_res == JNI_OK);
6743         }
6744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6745         CHECK(obj != NULL);
6746         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6747         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6748                 (*env)->ExceptionDescribe(env);
6749                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6750         }
6751         LDKThirtyTwoBytes ret_ref;
6752         CHECK((*env)->GetArrayLength(env, ret) == 32);
6753         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6754         if (get_jenv_res == JNI_EDETACHED) {
6755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6756         }
6757         return ret_ref;
6758 }
6759 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6760         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6761         JNIEnv *env;
6762         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6763         if (get_jenv_res == JNI_EDETACHED) {
6764                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6765         } else {
6766                 DO_ASSERT(get_jenv_res == JNI_OK);
6767         }
6768         LDKu8slice reader_var = reader;
6769         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6770         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6772         CHECK(obj != NULL);
6773         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6774         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6775                 (*env)->ExceptionDescribe(env);
6776                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6777         }
6778         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6779         CHECK_ACCESS(ret_ptr);
6780         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6781         FREE((void*)ret);
6782         if (get_jenv_res == JNI_EDETACHED) {
6783                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6784         }
6785         return ret_conv;
6786 }
6787 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6788         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6789         JNIEnv *env;
6790         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6791         if (get_jenv_res == JNI_EDETACHED) {
6792                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6793         } else {
6794                 DO_ASSERT(get_jenv_res == JNI_OK);
6795         }
6796         LDKu8slice hrp_bytes_var = hrp_bytes;
6797         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6798         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6799         LDKCVec_u5Z invoice_data_var = invoice_data;
6800         jobjectArray invoice_data_arr = NULL;
6801         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
6802         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
6803         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6804                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6805                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6806         }
6807         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
6808         FREE(invoice_data_var.data);
6809         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
6810         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6811         CHECK(obj != NULL);
6812         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
6813         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6814                 (*env)->ExceptionDescribe(env);
6815                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6816         }
6817         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6818         CHECK_ACCESS(ret_ptr);
6819         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6820         FREE((void*)ret);
6821         if (get_jenv_res == JNI_EDETACHED) {
6822                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6823         }
6824         return ret_conv;
6825 }
6826 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6827         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6828         JNIEnv *env;
6829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6830         if (get_jenv_res == JNI_EDETACHED) {
6831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6832         } else {
6833                 DO_ASSERT(get_jenv_res == JNI_OK);
6834         }
6835         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6836         CHECK(obj != NULL);
6837         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6838         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6839                 (*env)->ExceptionDescribe(env);
6840                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6841         }
6842         LDKThirtyTwoBytes ret_ref;
6843         CHECK((*env)->GetArrayLength(env, ret) == 32);
6844         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6845         if (get_jenv_res == JNI_EDETACHED) {
6846                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6847         }
6848         return ret_ref;
6849 }
6850 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6851         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6852         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6853 }
6854 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6855         jclass c = (*env)->GetObjectClass(env, o);
6856         CHECK(c != NULL);
6857         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6858         atomic_init(&calls->refcnt, 1);
6859         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6860         calls->o = (*env)->NewWeakGlobalRef(env, o);
6861         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6862         CHECK(calls->get_node_secret_meth != NULL);
6863         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6864         CHECK(calls->get_destination_script_meth != NULL);
6865         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6866         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6867         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6868         CHECK(calls->get_channel_signer_meth != NULL);
6869         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6870         CHECK(calls->get_secure_random_bytes_meth != NULL);
6871         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6872         CHECK(calls->read_chan_signer_meth != NULL);
6873         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6874         CHECK(calls->sign_invoice_meth != NULL);
6875         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6876         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6877
6878         LDKKeysInterface ret = {
6879                 .this_arg = (void*) calls,
6880                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6881                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6882                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6883                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6884                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6885                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6886                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6887                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6888                 .free = LDKKeysInterface_JCalls_free,
6889         };
6890         return ret;
6891 }
6892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6893         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6894         *res_ptr = LDKKeysInterface_init(env, clz, o);
6895         return (uint64_t)res_ptr;
6896 }
6897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6898         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6899         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6900         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6901         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6902         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6903         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6904         return (int64_t)ret_conv;
6905 }
6906
6907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6908         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6909         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6910         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6911         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6914         CVec_u8Z_free(ret_var);
6915         return ret_arr;
6916 }
6917
6918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6919         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6920         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6921         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6922         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6923         int64_t ret_ref = 0;
6924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6927         ret_ref = (uintptr_t)ret_var.inner;
6928         if (ret_var.is_owned) {
6929                 ret_ref |= 1;
6930         }
6931         return ret_ref;
6932 }
6933
6934 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) {
6935         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6936         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6937         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6938         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6939         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6940         return (int64_t)ret_ret;
6941 }
6942
6943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6944         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6945         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6946         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6947         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6948         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6949         return ret_arr;
6950 }
6951
6952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6953         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6954         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6955         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6956         LDKu8slice reader_ref;
6957         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6958         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6959         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6960         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6961         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6962         return (int64_t)ret_conv;
6963 }
6964
6965 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) {
6966         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6967         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6968         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6969         LDKu8slice hrp_bytes_ref;
6970         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6971         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6972         LDKCVec_u5Z invoice_data_constr;
6973         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6974         if (invoice_data_constr.datalen > 0)
6975                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6976         else
6977                 invoice_data_constr.data = NULL;
6978         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6979         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6980                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6981                 
6982                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6983         }
6984         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6985         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6986         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6987         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6988         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6989         return (int64_t)ret_conv;
6990 }
6991
6992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6993         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6994         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6995         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6996         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6997         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6998         return ret_arr;
6999 }
7000
7001 typedef struct LDKFeeEstimator_JCalls {
7002         atomic_size_t refcnt;
7003         JavaVM *vm;
7004         jweak o;
7005         jmethodID get_est_sat_per_1000_weight_meth;
7006 } LDKFeeEstimator_JCalls;
7007 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7008         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7009         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7010                 JNIEnv *env;
7011                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7012                 if (get_jenv_res == JNI_EDETACHED) {
7013                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7014                 } else {
7015                         DO_ASSERT(get_jenv_res == JNI_OK);
7016                 }
7017                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7018                 if (get_jenv_res == JNI_EDETACHED) {
7019                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7020                 }
7021                 FREE(j_calls);
7022         }
7023 }
7024 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7025         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7026         JNIEnv *env;
7027         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7028         if (get_jenv_res == JNI_EDETACHED) {
7029                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7030         } else {
7031                 DO_ASSERT(get_jenv_res == JNI_OK);
7032         }
7033         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7034         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7035         CHECK(obj != NULL);
7036         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7037         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7038                 (*env)->ExceptionDescribe(env);
7039                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7040         }
7041         if (get_jenv_res == JNI_EDETACHED) {
7042                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7043         }
7044         return ret;
7045 }
7046 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7047         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7048         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7049 }
7050 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7051         jclass c = (*env)->GetObjectClass(env, o);
7052         CHECK(c != NULL);
7053         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7054         atomic_init(&calls->refcnt, 1);
7055         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7056         calls->o = (*env)->NewWeakGlobalRef(env, o);
7057         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7058         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7059
7060         LDKFeeEstimator ret = {
7061                 .this_arg = (void*) calls,
7062                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7063                 .free = LDKFeeEstimator_JCalls_free,
7064         };
7065         return ret;
7066 }
7067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7068         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7069         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7070         return (uint64_t)res_ptr;
7071 }
7072 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) {
7073         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7074         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7075         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7076         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7077         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7078         return ret_conv;
7079 }
7080
7081 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7082         return ThirtyTwoBytes_clone(&owner->a);
7083 }
7084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7085         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7086         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7087         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7088         return ret_arr;
7089 }
7090
7091 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7092         return &owner->b;
7093 }
7094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7095         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7096         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7097         int64_t ret_ref = 0;
7098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7101         ret_ref = (uintptr_t)ret_var.inner & ~1;
7102         return ret_ref;
7103 }
7104
7105 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7106 CHECK(owner->result_ok);
7107         return &*owner->contents.result;
7108 }
7109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7110         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7111         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
7112         return ret_ret;
7113 }
7114
7115 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7116 CHECK(!owner->result_ok);
7117         return DecodeError_clone(&*owner->contents.err);
7118 }
7119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7120         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7121         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7122         int64_t ret_ref = 0;
7123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7126         ret_ref = (uintptr_t)ret_var.inner;
7127         if (ret_var.is_owned) {
7128                 ret_ref |= 1;
7129         }
7130         return ret_ref;
7131 }
7132
7133 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7134 CHECK(owner->result_ok);
7135         return ChannelConfig_clone(&*owner->contents.result);
7136 }
7137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7138         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7139         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7140         int64_t ret_ref = 0;
7141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7144         ret_ref = (uintptr_t)ret_var.inner;
7145         if (ret_var.is_owned) {
7146                 ret_ref |= 1;
7147         }
7148         return ret_ref;
7149 }
7150
7151 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7152 CHECK(!owner->result_ok);
7153         return DecodeError_clone(&*owner->contents.err);
7154 }
7155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7156         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7157         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7158         int64_t ret_ref = 0;
7159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7162         ret_ref = (uintptr_t)ret_var.inner;
7163         if (ret_var.is_owned) {
7164                 ret_ref |= 1;
7165         }
7166         return ret_ref;
7167 }
7168
7169 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7170 CHECK(owner->result_ok);
7171         return OutPoint_clone(&*owner->contents.result);
7172 }
7173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7174         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7175         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7176         int64_t ret_ref = 0;
7177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7180         ret_ref = (uintptr_t)ret_var.inner;
7181         if (ret_var.is_owned) {
7182                 ret_ref |= 1;
7183         }
7184         return ret_ref;
7185 }
7186
7187 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7188 CHECK(!owner->result_ok);
7189         return DecodeError_clone(&*owner->contents.err);
7190 }
7191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7192         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7193         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7194         int64_t ret_ref = 0;
7195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7198         ret_ref = (uintptr_t)ret_var.inner;
7199         if (ret_var.is_owned) {
7200                 ret_ref |= 1;
7201         }
7202         return ret_ref;
7203 }
7204
7205 typedef struct LDKType_JCalls {
7206         atomic_size_t refcnt;
7207         JavaVM *vm;
7208         jweak o;
7209         jmethodID type_id_meth;
7210         jmethodID debug_str_meth;
7211         jmethodID write_meth;
7212 } LDKType_JCalls;
7213 static void LDKType_JCalls_free(void* this_arg) {
7214         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7215         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7216                 JNIEnv *env;
7217                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7218                 if (get_jenv_res == JNI_EDETACHED) {
7219                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7220                 } else {
7221                         DO_ASSERT(get_jenv_res == JNI_OK);
7222                 }
7223                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7224                 if (get_jenv_res == JNI_EDETACHED) {
7225                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7226                 }
7227                 FREE(j_calls);
7228         }
7229 }
7230 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7231         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7232         JNIEnv *env;
7233         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7234         if (get_jenv_res == JNI_EDETACHED) {
7235                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7236         } else {
7237                 DO_ASSERT(get_jenv_res == JNI_OK);
7238         }
7239         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7240         CHECK(obj != NULL);
7241         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7242         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7243                 (*env)->ExceptionDescribe(env);
7244                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7245         }
7246         if (get_jenv_res == JNI_EDETACHED) {
7247                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7248         }
7249         return ret;
7250 }
7251 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7252         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7253         JNIEnv *env;
7254         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7255         if (get_jenv_res == JNI_EDETACHED) {
7256                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7257         } else {
7258                 DO_ASSERT(get_jenv_res == JNI_OK);
7259         }
7260         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7261         CHECK(obj != NULL);
7262         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7263         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7264                 (*env)->ExceptionDescribe(env);
7265                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7266         }
7267         LDKStr ret_conv = java_to_owned_str(env, ret);
7268         if (get_jenv_res == JNI_EDETACHED) {
7269                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7270         }
7271         return ret_conv;
7272 }
7273 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7274         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7275         JNIEnv *env;
7276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7277         if (get_jenv_res == JNI_EDETACHED) {
7278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7279         } else {
7280                 DO_ASSERT(get_jenv_res == JNI_OK);
7281         }
7282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7283         CHECK(obj != NULL);
7284         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7285         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7286                 (*env)->ExceptionDescribe(env);
7287                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7288         }
7289         LDKCVec_u8Z ret_ref;
7290         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7291         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7292         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7293         if (get_jenv_res == JNI_EDETACHED) {
7294                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7295         }
7296         return ret_ref;
7297 }
7298 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7299         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7300         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7301 }
7302 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7303         jclass c = (*env)->GetObjectClass(env, o);
7304         CHECK(c != NULL);
7305         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7306         atomic_init(&calls->refcnt, 1);
7307         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7308         calls->o = (*env)->NewWeakGlobalRef(env, o);
7309         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7310         CHECK(calls->type_id_meth != NULL);
7311         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7312         CHECK(calls->debug_str_meth != NULL);
7313         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7314         CHECK(calls->write_meth != NULL);
7315
7316         LDKType ret = {
7317                 .this_arg = (void*) calls,
7318                 .type_id = type_id_LDKType_jcall,
7319                 .debug_str = debug_str_LDKType_jcall,
7320                 .write = write_LDKType_jcall,
7321                 .cloned = LDKType_JCalls_cloned,
7322                 .free = LDKType_JCalls_free,
7323         };
7324         return ret;
7325 }
7326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7327         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7328         *res_ptr = LDKType_init(env, clz, o);
7329         return (uint64_t)res_ptr;
7330 }
7331 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7332         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7333         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7334         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7335         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7336         return ret_conv;
7337 }
7338
7339 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7340         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7341         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7342         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7343         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7344         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7345         Str_free(ret_str);
7346         return ret_conv;
7347 }
7348
7349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7350         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7351         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7352         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7353         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7354         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7355         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7356         CVec_u8Z_free(ret_var);
7357         return ret_arr;
7358 }
7359
7360 static jclass LDKCOption_TypeZ_Some_class = NULL;
7361 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7362 static jclass LDKCOption_TypeZ_None_class = NULL;
7363 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7365         LDKCOption_TypeZ_Some_class =
7366                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7367         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7368         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7369         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7370         LDKCOption_TypeZ_None_class =
7371                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7372         CHECK(LDKCOption_TypeZ_None_class != NULL);
7373         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7374         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7375 }
7376 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7377         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
7378         switch(obj->tag) {
7379                 case LDKCOption_TypeZ_Some: {
7380                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7381                         *some_ret = Type_clone(&obj->some);
7382                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
7383                 }
7384                 case LDKCOption_TypeZ_None: {
7385                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7386                 }
7387                 default: abort();
7388         }
7389 }
7390 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7391 CHECK(owner->result_ok);
7392         return COption_TypeZ_clone(&*owner->contents.result);
7393 }
7394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7395         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7396         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7397         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7398         int64_t ret_ref = (uintptr_t)ret_copy;
7399         return ret_ref;
7400 }
7401
7402 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7403 CHECK(!owner->result_ok);
7404         return DecodeError_clone(&*owner->contents.err);
7405 }
7406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7407         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7408         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7409         int64_t ret_ref = 0;
7410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7413         ret_ref = (uintptr_t)ret_var.inner;
7414         if (ret_var.is_owned) {
7415                 ret_ref |= 1;
7416         }
7417         return ret_ref;
7418 }
7419
7420 static jclass LDKPaymentError_Invoice_class = NULL;
7421 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7422 static jclass LDKPaymentError_Routing_class = NULL;
7423 static jmethodID LDKPaymentError_Routing_meth = NULL;
7424 static jclass LDKPaymentError_Sending_class = NULL;
7425 static jmethodID LDKPaymentError_Sending_meth = NULL;
7426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7427         LDKPaymentError_Invoice_class =
7428                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7429         CHECK(LDKPaymentError_Invoice_class != NULL);
7430         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7431         CHECK(LDKPaymentError_Invoice_meth != NULL);
7432         LDKPaymentError_Routing_class =
7433                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7434         CHECK(LDKPaymentError_Routing_class != NULL);
7435         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7436         CHECK(LDKPaymentError_Routing_meth != NULL);
7437         LDKPaymentError_Sending_class =
7438                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7439         CHECK(LDKPaymentError_Sending_class != NULL);
7440         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7441         CHECK(LDKPaymentError_Sending_meth != NULL);
7442 }
7443 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7444         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
7445         switch(obj->tag) {
7446                 case LDKPaymentError_Invoice: {
7447                         LDKStr invoice_str = obj->invoice;
7448                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7449                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7450                 }
7451                 case LDKPaymentError_Routing: {
7452                         LDKLightningError routing_var = obj->routing;
7453                         int64_t routing_ref = 0;
7454                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7455                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7456                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7457                         routing_ref = (uintptr_t)routing_var.inner & ~1;
7458                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7459                 }
7460                 case LDKPaymentError_Sending: {
7461                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
7462                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7463                 }
7464                 default: abort();
7465         }
7466 }
7467 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7468 CHECK(owner->result_ok);
7469         return ThirtyTwoBytes_clone(&*owner->contents.result);
7470 }
7471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7472         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7473         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7474         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7475         return ret_arr;
7476 }
7477
7478 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7479 CHECK(!owner->result_ok);
7480         return PaymentError_clone(&*owner->contents.err);
7481 }
7482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7483         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7484         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7485         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7486         int64_t ret_ref = (uintptr_t)ret_copy;
7487         return ret_ref;
7488 }
7489
7490 static jclass LDKParseError_Bech32Error_class = NULL;
7491 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7492 static jclass LDKParseError_ParseAmountError_class = NULL;
7493 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7494 static jclass LDKParseError_MalformedSignature_class = NULL;
7495 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7496 static jclass LDKParseError_BadPrefix_class = NULL;
7497 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7498 static jclass LDKParseError_UnknownCurrency_class = NULL;
7499 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7500 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7501 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7502 static jclass LDKParseError_MalformedHRP_class = NULL;
7503 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7504 static jclass LDKParseError_TooShortDataPart_class = NULL;
7505 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7506 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7507 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7508 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7509 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7510 static jclass LDKParseError_PaddingError_class = NULL;
7511 static jmethodID LDKParseError_PaddingError_meth = NULL;
7512 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7513 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7514 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7515 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7516 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7517 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7518 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7519 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7520 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7521 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7522 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7523 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7524 static jclass LDKParseError_Skip_class = NULL;
7525 static jmethodID LDKParseError_Skip_meth = NULL;
7526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7527         LDKParseError_Bech32Error_class =
7528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7529         CHECK(LDKParseError_Bech32Error_class != NULL);
7530         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7531         CHECK(LDKParseError_Bech32Error_meth != NULL);
7532         LDKParseError_ParseAmountError_class =
7533                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7534         CHECK(LDKParseError_ParseAmountError_class != NULL);
7535         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7536         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7537         LDKParseError_MalformedSignature_class =
7538                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7539         CHECK(LDKParseError_MalformedSignature_class != NULL);
7540         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7541         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7542         LDKParseError_BadPrefix_class =
7543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7544         CHECK(LDKParseError_BadPrefix_class != NULL);
7545         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7546         CHECK(LDKParseError_BadPrefix_meth != NULL);
7547         LDKParseError_UnknownCurrency_class =
7548                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7549         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7550         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7551         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7552         LDKParseError_UnknownSiPrefix_class =
7553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7554         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7555         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7556         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7557         LDKParseError_MalformedHRP_class =
7558                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7559         CHECK(LDKParseError_MalformedHRP_class != NULL);
7560         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7561         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7562         LDKParseError_TooShortDataPart_class =
7563                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7564         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7565         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7566         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7567         LDKParseError_UnexpectedEndOfTaggedFields_class =
7568                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7569         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7570         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7571         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7572         LDKParseError_DescriptionDecodeError_class =
7573                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7574         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7575         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7576         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7577         LDKParseError_PaddingError_class =
7578                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7579         CHECK(LDKParseError_PaddingError_class != NULL);
7580         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7581         CHECK(LDKParseError_PaddingError_meth != NULL);
7582         LDKParseError_IntegerOverflowError_class =
7583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7584         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7585         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7586         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7587         LDKParseError_InvalidSegWitProgramLength_class =
7588                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7589         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7590         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7591         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7592         LDKParseError_InvalidPubKeyHashLength_class =
7593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7594         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7595         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7596         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7597         LDKParseError_InvalidScriptHashLength_class =
7598                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7599         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7600         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7601         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7602         LDKParseError_InvalidRecoveryId_class =
7603                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7604         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7605         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7606         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7607         LDKParseError_InvalidSliceLength_class =
7608                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7609         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7610         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7611         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7612         LDKParseError_Skip_class =
7613                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7614         CHECK(LDKParseError_Skip_class != NULL);
7615         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7616         CHECK(LDKParseError_Skip_meth != NULL);
7617 }
7618 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7619         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
7620         switch(obj->tag) {
7621                 case LDKParseError_Bech32Error: {
7622                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
7623                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7624                 }
7625                 case LDKParseError_ParseAmountError: {
7626                         /*obj->parse_amount_error*/
7627                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7628                 }
7629                 case LDKParseError_MalformedSignature: {
7630                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7631                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7632                 }
7633                 case LDKParseError_BadPrefix: {
7634                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7635                 }
7636                 case LDKParseError_UnknownCurrency: {
7637                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7638                 }
7639                 case LDKParseError_UnknownSiPrefix: {
7640                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7641                 }
7642                 case LDKParseError_MalformedHRP: {
7643                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7644                 }
7645                 case LDKParseError_TooShortDataPart: {
7646                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7647                 }
7648                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7649                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7650                 }
7651                 case LDKParseError_DescriptionDecodeError: {
7652                         /*obj->description_decode_error*/
7653                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7654                 }
7655                 case LDKParseError_PaddingError: {
7656                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7657                 }
7658                 case LDKParseError_IntegerOverflowError: {
7659                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7660                 }
7661                 case LDKParseError_InvalidSegWitProgramLength: {
7662                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7663                 }
7664                 case LDKParseError_InvalidPubKeyHashLength: {
7665                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7666                 }
7667                 case LDKParseError_InvalidScriptHashLength: {
7668                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7669                 }
7670                 case LDKParseError_InvalidRecoveryId: {
7671                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7672                 }
7673                 case LDKParseError_InvalidSliceLength: {
7674                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7675                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7676                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7677                 }
7678                 case LDKParseError_Skip: {
7679                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7680                 }
7681                 default: abort();
7682         }
7683 }
7684 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7685 CHECK(owner->result_ok);
7686         return SiPrefix_clone(&*owner->contents.result);
7687 }
7688 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7689         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7690         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7691         return ret_conv;
7692 }
7693
7694 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7695 CHECK(!owner->result_ok);
7696         return ParseError_clone(&*owner->contents.err);
7697 }
7698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7699         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7700         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7701         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7702         int64_t ret_ref = (uintptr_t)ret_copy;
7703         return ret_ref;
7704 }
7705
7706 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7707 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7708 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7709 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7711         LDKParseOrSemanticError_ParseError_class =
7712                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7713         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7714         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7715         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7716         LDKParseOrSemanticError_SemanticError_class =
7717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7718         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7719         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7720         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7721 }
7722 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7723         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7724         switch(obj->tag) {
7725                 case LDKParseOrSemanticError_ParseError: {
7726                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7727                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7728                 }
7729                 case LDKParseOrSemanticError_SemanticError: {
7730                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7731                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7732                 }
7733                 default: abort();
7734         }
7735 }
7736 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7737 CHECK(owner->result_ok);
7738         return Invoice_clone(&*owner->contents.result);
7739 }
7740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7741         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7742         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7743         int64_t ret_ref = 0;
7744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7747         ret_ref = (uintptr_t)ret_var.inner;
7748         if (ret_var.is_owned) {
7749                 ret_ref |= 1;
7750         }
7751         return ret_ref;
7752 }
7753
7754 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7755 CHECK(!owner->result_ok);
7756         return ParseOrSemanticError_clone(&*owner->contents.err);
7757 }
7758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7759         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7760         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7761         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7762         int64_t ret_ref = (uintptr_t)ret_copy;
7763         return ret_ref;
7764 }
7765
7766 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7767 CHECK(owner->result_ok);
7768         return SignedRawInvoice_clone(&*owner->contents.result);
7769 }
7770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7771         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7772         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7773         int64_t ret_ref = 0;
7774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7777         ret_ref = (uintptr_t)ret_var.inner;
7778         if (ret_var.is_owned) {
7779                 ret_ref |= 1;
7780         }
7781         return ret_ref;
7782 }
7783
7784 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7785 CHECK(!owner->result_ok);
7786         return ParseError_clone(&*owner->contents.err);
7787 }
7788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7789         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7790         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7791         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7792         int64_t ret_ref = (uintptr_t)ret_copy;
7793         return ret_ref;
7794 }
7795
7796 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7797         return RawInvoice_clone(&owner->a);
7798 }
7799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7800         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7801         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7802         int64_t ret_ref = 0;
7803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7806         ret_ref = (uintptr_t)ret_var.inner;
7807         if (ret_var.is_owned) {
7808                 ret_ref |= 1;
7809         }
7810         return ret_ref;
7811 }
7812
7813 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7814         return ThirtyTwoBytes_clone(&owner->b);
7815 }
7816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7817         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7820         return ret_arr;
7821 }
7822
7823 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7824         return InvoiceSignature_clone(&owner->c);
7825 }
7826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7827         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7828         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7829         int64_t ret_ref = 0;
7830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7833         ret_ref = (uintptr_t)ret_var.inner;
7834         if (ret_var.is_owned) {
7835                 ret_ref |= 1;
7836         }
7837         return ret_ref;
7838 }
7839
7840 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7841 CHECK(owner->result_ok);
7842         return PayeePubKey_clone(&*owner->contents.result);
7843 }
7844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7845         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7846         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7847         int64_t ret_ref = 0;
7848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7851         ret_ref = (uintptr_t)ret_var.inner;
7852         if (ret_var.is_owned) {
7853                 ret_ref |= 1;
7854         }
7855         return ret_ref;
7856 }
7857
7858 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7859 CHECK(!owner->result_ok);
7860         return *owner->contents.err;
7861 }
7862 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7863         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7864         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7865         return ret_conv;
7866 }
7867
7868 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7869         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7870         for (size_t i = 0; i < ret.datalen; i++) {
7871                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7872         }
7873         return ret;
7874 }
7875 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7876 CHECK(owner->result_ok);
7877         return PositiveTimestamp_clone(&*owner->contents.result);
7878 }
7879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7880         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7881         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7882         int64_t ret_ref = 0;
7883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7886         ret_ref = (uintptr_t)ret_var.inner;
7887         if (ret_var.is_owned) {
7888                 ret_ref |= 1;
7889         }
7890         return ret_ref;
7891 }
7892
7893 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7894 CHECK(!owner->result_ok);
7895         return CreationError_clone(&*owner->contents.err);
7896 }
7897 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7898         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7899         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7900         return ret_conv;
7901 }
7902
7903 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7904 CHECK(owner->result_ok);
7905         return *owner->contents.result;
7906 }
7907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7908         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7909         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7910 }
7911
7912 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7913 CHECK(!owner->result_ok);
7914         return SemanticError_clone(&*owner->contents.err);
7915 }
7916 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7917         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7918         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7919         return ret_conv;
7920 }
7921
7922 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7923 CHECK(owner->result_ok);
7924         return Invoice_clone(&*owner->contents.result);
7925 }
7926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7927         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7928         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7929         int64_t ret_ref = 0;
7930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7933         ret_ref = (uintptr_t)ret_var.inner;
7934         if (ret_var.is_owned) {
7935                 ret_ref |= 1;
7936         }
7937         return ret_ref;
7938 }
7939
7940 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7941 CHECK(!owner->result_ok);
7942         return SemanticError_clone(&*owner->contents.err);
7943 }
7944 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7945         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7946         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7947         return ret_conv;
7948 }
7949
7950 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7951 CHECK(owner->result_ok);
7952         return Description_clone(&*owner->contents.result);
7953 }
7954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7955         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7956         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7957         int64_t ret_ref = 0;
7958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7961         ret_ref = (uintptr_t)ret_var.inner;
7962         if (ret_var.is_owned) {
7963                 ret_ref |= 1;
7964         }
7965         return ret_ref;
7966 }
7967
7968 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7969 CHECK(!owner->result_ok);
7970         return CreationError_clone(&*owner->contents.err);
7971 }
7972 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7973         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7974         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7975         return ret_conv;
7976 }
7977
7978 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7979 CHECK(owner->result_ok);
7980         return PrivateRoute_clone(&*owner->contents.result);
7981 }
7982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7983         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7984         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7985         int64_t ret_ref = 0;
7986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7989         ret_ref = (uintptr_t)ret_var.inner;
7990         if (ret_var.is_owned) {
7991                 ret_ref |= 1;
7992         }
7993         return ret_ref;
7994 }
7995
7996 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7997 CHECK(!owner->result_ok);
7998         return CreationError_clone(&*owner->contents.err);
7999 }
8000 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8001         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8002         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8003         return ret_conv;
8004 }
8005
8006 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8007 CHECK(owner->result_ok);
8008         return *owner->contents.result;
8009 }
8010 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8011         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8012         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8013         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8014         return ret_conv;
8015 }
8016
8017 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8018 CHECK(!owner->result_ok);
8019         return *owner->contents.err;
8020 }
8021 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8022         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8023         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8024         return ret_conv;
8025 }
8026
8027 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8028 CHECK(owner->result_ok);
8029         return ChannelMonitorUpdate_clone(&*owner->contents.result);
8030 }
8031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8032         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8033         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8034         int64_t ret_ref = 0;
8035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8038         ret_ref = (uintptr_t)ret_var.inner;
8039         if (ret_var.is_owned) {
8040                 ret_ref |= 1;
8041         }
8042         return ret_ref;
8043 }
8044
8045 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8046 CHECK(!owner->result_ok);
8047         return DecodeError_clone(&*owner->contents.err);
8048 }
8049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8050         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8051         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8052         int64_t ret_ref = 0;
8053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8056         ret_ref = (uintptr_t)ret_var.inner;
8057         if (ret_var.is_owned) {
8058                 ret_ref |= 1;
8059         }
8060         return ret_ref;
8061 }
8062
8063 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8064 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8065 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8066 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8068         LDKCOption_MonitorEventZ_Some_class =
8069                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8070         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8071         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8072         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8073         LDKCOption_MonitorEventZ_None_class =
8074                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8075         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8076         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8077         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8078 }
8079 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8080         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
8081         switch(obj->tag) {
8082                 case LDKCOption_MonitorEventZ_Some: {
8083                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8084                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8085                 }
8086                 case LDKCOption_MonitorEventZ_None: {
8087                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8088                 }
8089                 default: abort();
8090         }
8091 }
8092 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8093 CHECK(owner->result_ok);
8094         return COption_MonitorEventZ_clone(&*owner->contents.result);
8095 }
8096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8097         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8098         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8099         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8100         int64_t ret_ref = (uintptr_t)ret_copy;
8101         return ret_ref;
8102 }
8103
8104 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8105 CHECK(!owner->result_ok);
8106         return DecodeError_clone(&*owner->contents.err);
8107 }
8108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8109         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8110         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8111         int64_t ret_ref = 0;
8112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8115         ret_ref = (uintptr_t)ret_var.inner;
8116         if (ret_var.is_owned) {
8117                 ret_ref |= 1;
8118         }
8119         return ret_ref;
8120 }
8121
8122 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8123 CHECK(owner->result_ok);
8124         return HTLCUpdate_clone(&*owner->contents.result);
8125 }
8126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8127         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8128         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8129         int64_t ret_ref = 0;
8130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8133         ret_ref = (uintptr_t)ret_var.inner;
8134         if (ret_var.is_owned) {
8135                 ret_ref |= 1;
8136         }
8137         return ret_ref;
8138 }
8139
8140 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8141 CHECK(!owner->result_ok);
8142         return DecodeError_clone(&*owner->contents.err);
8143 }
8144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8145         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8146         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8147         int64_t ret_ref = 0;
8148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8151         ret_ref = (uintptr_t)ret_var.inner;
8152         if (ret_var.is_owned) {
8153                 ret_ref |= 1;
8154         }
8155         return ret_ref;
8156 }
8157
8158 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8159         return OutPoint_clone(&owner->a);
8160 }
8161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8162         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8163         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8164         int64_t ret_ref = 0;
8165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8168         ret_ref = (uintptr_t)ret_var.inner;
8169         if (ret_var.is_owned) {
8170                 ret_ref |= 1;
8171         }
8172         return ret_ref;
8173 }
8174
8175 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8176         return CVec_u8Z_clone(&owner->b);
8177 }
8178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8179         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8180         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8183         CVec_u8Z_free(ret_var);
8184         return ret_arr;
8185 }
8186
8187 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8188         return owner->a;
8189 }
8190 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8191         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8192         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8193         return ret_conv;
8194 }
8195
8196 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8197         return CVec_u8Z_clone(&owner->b);
8198 }
8199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8200         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8201         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8204         CVec_u8Z_free(ret_var);
8205         return ret_arr;
8206 }
8207
8208 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8209         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8210         for (size_t i = 0; i < ret.datalen; i++) {
8211                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8212         }
8213         return ret;
8214 }
8215 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8216         return ThirtyTwoBytes_clone(&owner->a);
8217 }
8218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8219         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8222         return ret_arr;
8223 }
8224
8225 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8226         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8227 }
8228 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8229         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8230         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8231         int64_tArray ret_arr = NULL;
8232         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8233         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8234         for (size_t v = 0; v < ret_var.datalen; v++) {
8235                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8236                 *ret_conv_21_conv = ret_var.data[v];
8237                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
8238         }
8239         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8240         FREE(ret_var.data);
8241         return ret_arr;
8242 }
8243
8244 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8245         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 };
8246         for (size_t i = 0; i < ret.datalen; i++) {
8247                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8248         }
8249         return ret;
8250 }
8251 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8252         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8253         for (size_t i = 0; i < ret.datalen; i++) {
8254                 ret.data[i] = Event_clone(&orig->data[i]);
8255         }
8256         return ret;
8257 }
8258 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8259         return owner->a;
8260 }
8261 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8262         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8263         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8264         return ret_conv;
8265 }
8266
8267 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8268         return TxOut_clone(&owner->b);
8269 }
8270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8271         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8272         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8273         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8274         return (int64_t)ret_ref;
8275 }
8276
8277 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8278         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8279         for (size_t i = 0; i < ret.datalen; i++) {
8280                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8281         }
8282         return ret;
8283 }
8284 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8285         return ThirtyTwoBytes_clone(&owner->a);
8286 }
8287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8288         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8291         return ret_arr;
8292 }
8293
8294 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8295         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8296 }
8297 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8298         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8299         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8300         int64_tArray ret_arr = NULL;
8301         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8302         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8303         for (size_t u = 0; u < ret_var.datalen; u++) {
8304                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8305                 *ret_conv_20_conv = ret_var.data[u];
8306                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
8307         }
8308         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8309         FREE(ret_var.data);
8310         return ret_arr;
8311 }
8312
8313 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8314         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 };
8315         for (size_t i = 0; i < ret.datalen; i++) {
8316                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8317         }
8318         return ret;
8319 }
8320 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8321 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8322 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8323 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8324 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8325 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8326 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
8327 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
8328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8329         LDKBalance_ClaimableOnChannelClose_class =
8330                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8331         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8332         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8333         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8334         LDKBalance_ClaimableAwaitingConfirmations_class =
8335                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8336         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8337         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8338         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8339         LDKBalance_ContentiousClaimable_class =
8340                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8341         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8342         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8343         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8344         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
8345                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
8346         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
8347         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
8348         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
8349 }
8350 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8351         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
8352         switch(obj->tag) {
8353                 case LDKBalance_ClaimableOnChannelClose: {
8354                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8355                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8356                 }
8357                 case LDKBalance_ClaimableAwaitingConfirmations: {
8358                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8359                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8360                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8361                 }
8362                 case LDKBalance_ContentiousClaimable: {
8363                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8364                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8365                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8366                 }
8367                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
8368                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
8369                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
8370                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8371                 }
8372                 default: abort();
8373         }
8374 }
8375 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8376         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8377         for (size_t i = 0; i < ret.datalen; i++) {
8378                 ret.data[i] = Balance_clone(&orig->data[i]);
8379         }
8380         return ret;
8381 }
8382 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8383 CHECK(owner->result_ok);
8384         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8385 }
8386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8387         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8388         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8389         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8390         return ((int64_t)ret_conv);
8391 }
8392
8393 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8394 CHECK(!owner->result_ok);
8395         return DecodeError_clone(&*owner->contents.err);
8396 }
8397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8398         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8399         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8400         int64_t ret_ref = 0;
8401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8404         ret_ref = (uintptr_t)ret_var.inner;
8405         if (ret_var.is_owned) {
8406                 ret_ref |= 1;
8407         }
8408         return ret_ref;
8409 }
8410
8411 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8412         return owner->a;
8413 }
8414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8415         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8416         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8418         return ret_arr;
8419 }
8420
8421 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8422         return Type_clone(&owner->b);
8423 }
8424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8425         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8426         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8427         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8428         return (int64_t)ret_ret;
8429 }
8430
8431 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8432         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8433         for (size_t i = 0; i < ret.datalen; i++) {
8434                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8435         }
8436         return ret;
8437 }
8438 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8439 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8440 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8441 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8443         LDKCOption_NetAddressZ_Some_class =
8444                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8445         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8446         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8447         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8448         LDKCOption_NetAddressZ_None_class =
8449                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8450         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8451         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8452         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8453 }
8454 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8455         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
8456         switch(obj->tag) {
8457                 case LDKCOption_NetAddressZ_Some: {
8458                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8459                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8460                 }
8461                 case LDKCOption_NetAddressZ_None: {
8462                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8463                 }
8464                 default: abort();
8465         }
8466 }
8467 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8468 CHECK(owner->result_ok);
8469         return CVec_u8Z_clone(&*owner->contents.result);
8470 }
8471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8472         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8473         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8476         CVec_u8Z_free(ret_var);
8477         return ret_arr;
8478 }
8479
8480 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8481 CHECK(!owner->result_ok);
8482         return PeerHandleError_clone(&*owner->contents.err);
8483 }
8484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8485         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8486         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8487         int64_t ret_ref = 0;
8488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8491         ret_ref = (uintptr_t)ret_var.inner;
8492         if (ret_var.is_owned) {
8493                 ret_ref |= 1;
8494         }
8495         return ret_ref;
8496 }
8497
8498 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8499 CHECK(owner->result_ok);
8500         return *owner->contents.result;
8501 }
8502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8503         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8504         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8505 }
8506
8507 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8508 CHECK(!owner->result_ok);
8509         return PeerHandleError_clone(&*owner->contents.err);
8510 }
8511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8512         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8513         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8514         int64_t ret_ref = 0;
8515         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8516         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8518         ret_ref = (uintptr_t)ret_var.inner;
8519         if (ret_var.is_owned) {
8520                 ret_ref |= 1;
8521         }
8522         return ret_ref;
8523 }
8524
8525 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8526 CHECK(owner->result_ok);
8527         return *owner->contents.result;
8528 }
8529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8530         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8531         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8532         return ret_conv;
8533 }
8534
8535 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8536 CHECK(!owner->result_ok);
8537         return PeerHandleError_clone(&*owner->contents.err);
8538 }
8539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8540         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8541         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8542         int64_t ret_ref = 0;
8543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8546         ret_ref = (uintptr_t)ret_var.inner;
8547         if (ret_var.is_owned) {
8548                 ret_ref |= 1;
8549         }
8550         return ret_ref;
8551 }
8552
8553 static jclass LDKGraphSyncError_DecodeError_class = NULL;
8554 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8555 static jclass LDKGraphSyncError_LightningError_class = NULL;
8556 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8558         LDKGraphSyncError_DecodeError_class =
8559                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8560         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8561         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8562         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8563         LDKGraphSyncError_LightningError_class =
8564                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8565         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8566         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8567         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8568 }
8569 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8570         LDKGraphSyncError *obj = (LDKGraphSyncError*)(ptr & ~1);
8571         switch(obj->tag) {
8572                 case LDKGraphSyncError_DecodeError: {
8573                         LDKDecodeError decode_error_var = obj->decode_error;
8574                         int64_t decode_error_ref = 0;
8575                         CHECK((((uintptr_t)decode_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8576                         CHECK((((uintptr_t)&decode_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8577                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8578                         decode_error_ref = (uintptr_t)decode_error_var.inner & ~1;
8579                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8580                 }
8581                 case LDKGraphSyncError_LightningError: {
8582                         LDKLightningError lightning_error_var = obj->lightning_error;
8583                         int64_t lightning_error_ref = 0;
8584                         CHECK((((uintptr_t)lightning_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8585                         CHECK((((uintptr_t)&lightning_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8586                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8587                         lightning_error_ref = (uintptr_t)lightning_error_var.inner & ~1;
8588                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8589                 }
8590                 default: abort();
8591         }
8592 }
8593 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8594 CHECK(owner->result_ok);
8595         return *owner->contents.result;
8596 }
8597 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8598         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8599         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8600         return ret_conv;
8601 }
8602
8603 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8604 CHECK(!owner->result_ok);
8605         return GraphSyncError_clone(&*owner->contents.err);
8606 }
8607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8608         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8609         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8610         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8611         int64_t ret_ref = (uintptr_t)ret_copy;
8612         return ret_ref;
8613 }
8614
8615 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8616 CHECK(owner->result_ok);
8617         return NetAddress_clone(&*owner->contents.result);
8618 }
8619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8620         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8621         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8622         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8623         int64_t ret_ref = (uintptr_t)ret_copy;
8624         return ret_ref;
8625 }
8626
8627 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8628 CHECK(!owner->result_ok);
8629         return DecodeError_clone(&*owner->contents.err);
8630 }
8631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8632         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8633         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8634         int64_t ret_ref = 0;
8635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8638         ret_ref = (uintptr_t)ret_var.inner;
8639         if (ret_var.is_owned) {
8640                 ret_ref |= 1;
8641         }
8642         return ret_ref;
8643 }
8644
8645 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8646         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8647         for (size_t i = 0; i < ret.datalen; i++) {
8648                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8649         }
8650         return ret;
8651 }
8652 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8653         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8654         for (size_t i = 0; i < ret.datalen; i++) {
8655                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8656         }
8657         return ret;
8658 }
8659 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8660         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8661         for (size_t i = 0; i < ret.datalen; i++) {
8662                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8663         }
8664         return ret;
8665 }
8666 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8667         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8668         for (size_t i = 0; i < ret.datalen; i++) {
8669                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8670         }
8671         return ret;
8672 }
8673 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8674 CHECK(owner->result_ok);
8675         return AcceptChannel_clone(&*owner->contents.result);
8676 }
8677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8678         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8679         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8680         int64_t ret_ref = 0;
8681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8684         ret_ref = (uintptr_t)ret_var.inner;
8685         if (ret_var.is_owned) {
8686                 ret_ref |= 1;
8687         }
8688         return ret_ref;
8689 }
8690
8691 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8692 CHECK(!owner->result_ok);
8693         return DecodeError_clone(&*owner->contents.err);
8694 }
8695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8696         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8697         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8698         int64_t ret_ref = 0;
8699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8702         ret_ref = (uintptr_t)ret_var.inner;
8703         if (ret_var.is_owned) {
8704                 ret_ref |= 1;
8705         }
8706         return ret_ref;
8707 }
8708
8709 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8710 CHECK(owner->result_ok);
8711         return AnnouncementSignatures_clone(&*owner->contents.result);
8712 }
8713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8714         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8715         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8716         int64_t ret_ref = 0;
8717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8720         ret_ref = (uintptr_t)ret_var.inner;
8721         if (ret_var.is_owned) {
8722                 ret_ref |= 1;
8723         }
8724         return ret_ref;
8725 }
8726
8727 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8728 CHECK(!owner->result_ok);
8729         return DecodeError_clone(&*owner->contents.err);
8730 }
8731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8732         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8733         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8734         int64_t ret_ref = 0;
8735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8738         ret_ref = (uintptr_t)ret_var.inner;
8739         if (ret_var.is_owned) {
8740                 ret_ref |= 1;
8741         }
8742         return ret_ref;
8743 }
8744
8745 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8746 CHECK(owner->result_ok);
8747         return ChannelReestablish_clone(&*owner->contents.result);
8748 }
8749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8750         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8751         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8752         int64_t ret_ref = 0;
8753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8756         ret_ref = (uintptr_t)ret_var.inner;
8757         if (ret_var.is_owned) {
8758                 ret_ref |= 1;
8759         }
8760         return ret_ref;
8761 }
8762
8763 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8764 CHECK(!owner->result_ok);
8765         return DecodeError_clone(&*owner->contents.err);
8766 }
8767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8768         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8769         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8770         int64_t ret_ref = 0;
8771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8774         ret_ref = (uintptr_t)ret_var.inner;
8775         if (ret_var.is_owned) {
8776                 ret_ref |= 1;
8777         }
8778         return ret_ref;
8779 }
8780
8781 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8782 CHECK(owner->result_ok);
8783         return ClosingSigned_clone(&*owner->contents.result);
8784 }
8785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8786         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8787         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8788         int64_t ret_ref = 0;
8789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8792         ret_ref = (uintptr_t)ret_var.inner;
8793         if (ret_var.is_owned) {
8794                 ret_ref |= 1;
8795         }
8796         return ret_ref;
8797 }
8798
8799 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8800 CHECK(!owner->result_ok);
8801         return DecodeError_clone(&*owner->contents.err);
8802 }
8803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8804         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8805         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8806         int64_t ret_ref = 0;
8807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8810         ret_ref = (uintptr_t)ret_var.inner;
8811         if (ret_var.is_owned) {
8812                 ret_ref |= 1;
8813         }
8814         return ret_ref;
8815 }
8816
8817 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8818 CHECK(owner->result_ok);
8819         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8820 }
8821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8822         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8823         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8824         int64_t ret_ref = 0;
8825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8828         ret_ref = (uintptr_t)ret_var.inner;
8829         if (ret_var.is_owned) {
8830                 ret_ref |= 1;
8831         }
8832         return ret_ref;
8833 }
8834
8835 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8836 CHECK(!owner->result_ok);
8837         return DecodeError_clone(&*owner->contents.err);
8838 }
8839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8840         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8841         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8842         int64_t ret_ref = 0;
8843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8846         ret_ref = (uintptr_t)ret_var.inner;
8847         if (ret_var.is_owned) {
8848                 ret_ref |= 1;
8849         }
8850         return ret_ref;
8851 }
8852
8853 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8854 CHECK(owner->result_ok);
8855         return CommitmentSigned_clone(&*owner->contents.result);
8856 }
8857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8858         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8859         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8860         int64_t ret_ref = 0;
8861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8864         ret_ref = (uintptr_t)ret_var.inner;
8865         if (ret_var.is_owned) {
8866                 ret_ref |= 1;
8867         }
8868         return ret_ref;
8869 }
8870
8871 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8872 CHECK(!owner->result_ok);
8873         return DecodeError_clone(&*owner->contents.err);
8874 }
8875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8876         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8877         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8878         int64_t ret_ref = 0;
8879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8882         ret_ref = (uintptr_t)ret_var.inner;
8883         if (ret_var.is_owned) {
8884                 ret_ref |= 1;
8885         }
8886         return ret_ref;
8887 }
8888
8889 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8890 CHECK(owner->result_ok);
8891         return FundingCreated_clone(&*owner->contents.result);
8892 }
8893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8894         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8895         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8896         int64_t ret_ref = 0;
8897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8900         ret_ref = (uintptr_t)ret_var.inner;
8901         if (ret_var.is_owned) {
8902                 ret_ref |= 1;
8903         }
8904         return ret_ref;
8905 }
8906
8907 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8908 CHECK(!owner->result_ok);
8909         return DecodeError_clone(&*owner->contents.err);
8910 }
8911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8912         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8913         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8914         int64_t ret_ref = 0;
8915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8918         ret_ref = (uintptr_t)ret_var.inner;
8919         if (ret_var.is_owned) {
8920                 ret_ref |= 1;
8921         }
8922         return ret_ref;
8923 }
8924
8925 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8926 CHECK(owner->result_ok);
8927         return FundingSigned_clone(&*owner->contents.result);
8928 }
8929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8930         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8931         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8932         int64_t ret_ref = 0;
8933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8936         ret_ref = (uintptr_t)ret_var.inner;
8937         if (ret_var.is_owned) {
8938                 ret_ref |= 1;
8939         }
8940         return ret_ref;
8941 }
8942
8943 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8944 CHECK(!owner->result_ok);
8945         return DecodeError_clone(&*owner->contents.err);
8946 }
8947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8948         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8949         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8950         int64_t ret_ref = 0;
8951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8954         ret_ref = (uintptr_t)ret_var.inner;
8955         if (ret_var.is_owned) {
8956                 ret_ref |= 1;
8957         }
8958         return ret_ref;
8959 }
8960
8961 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8962 CHECK(owner->result_ok);
8963         return ChannelReady_clone(&*owner->contents.result);
8964 }
8965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8966         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
8967         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
8968         int64_t ret_ref = 0;
8969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8972         ret_ref = (uintptr_t)ret_var.inner;
8973         if (ret_var.is_owned) {
8974                 ret_ref |= 1;
8975         }
8976         return ret_ref;
8977 }
8978
8979 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8980 CHECK(!owner->result_ok);
8981         return DecodeError_clone(&*owner->contents.err);
8982 }
8983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8984         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
8985         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
8986         int64_t ret_ref = 0;
8987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8990         ret_ref = (uintptr_t)ret_var.inner;
8991         if (ret_var.is_owned) {
8992                 ret_ref |= 1;
8993         }
8994         return ret_ref;
8995 }
8996
8997 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8998 CHECK(owner->result_ok);
8999         return Init_clone(&*owner->contents.result);
9000 }
9001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9002         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9003         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9004         int64_t ret_ref = 0;
9005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9008         ret_ref = (uintptr_t)ret_var.inner;
9009         if (ret_var.is_owned) {
9010                 ret_ref |= 1;
9011         }
9012         return ret_ref;
9013 }
9014
9015 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9016 CHECK(!owner->result_ok);
9017         return DecodeError_clone(&*owner->contents.err);
9018 }
9019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9020         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9021         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
9022         int64_t ret_ref = 0;
9023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9026         ret_ref = (uintptr_t)ret_var.inner;
9027         if (ret_var.is_owned) {
9028                 ret_ref |= 1;
9029         }
9030         return ret_ref;
9031 }
9032
9033 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9034 CHECK(owner->result_ok);
9035         return OpenChannel_clone(&*owner->contents.result);
9036 }
9037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9038         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9039         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9040         int64_t ret_ref = 0;
9041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9044         ret_ref = (uintptr_t)ret_var.inner;
9045         if (ret_var.is_owned) {
9046                 ret_ref |= 1;
9047         }
9048         return ret_ref;
9049 }
9050
9051 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9052 CHECK(!owner->result_ok);
9053         return DecodeError_clone(&*owner->contents.err);
9054 }
9055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9056         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9057         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9058         int64_t ret_ref = 0;
9059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9062         ret_ref = (uintptr_t)ret_var.inner;
9063         if (ret_var.is_owned) {
9064                 ret_ref |= 1;
9065         }
9066         return ret_ref;
9067 }
9068
9069 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9070 CHECK(owner->result_ok);
9071         return RevokeAndACK_clone(&*owner->contents.result);
9072 }
9073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9074         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9075         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9076         int64_t ret_ref = 0;
9077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9080         ret_ref = (uintptr_t)ret_var.inner;
9081         if (ret_var.is_owned) {
9082                 ret_ref |= 1;
9083         }
9084         return ret_ref;
9085 }
9086
9087 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9088 CHECK(!owner->result_ok);
9089         return DecodeError_clone(&*owner->contents.err);
9090 }
9091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9092         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9093         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9094         int64_t ret_ref = 0;
9095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9098         ret_ref = (uintptr_t)ret_var.inner;
9099         if (ret_var.is_owned) {
9100                 ret_ref |= 1;
9101         }
9102         return ret_ref;
9103 }
9104
9105 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9106 CHECK(owner->result_ok);
9107         return Shutdown_clone(&*owner->contents.result);
9108 }
9109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9110         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9111         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9112         int64_t ret_ref = 0;
9113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9116         ret_ref = (uintptr_t)ret_var.inner;
9117         if (ret_var.is_owned) {
9118                 ret_ref |= 1;
9119         }
9120         return ret_ref;
9121 }
9122
9123 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9124 CHECK(!owner->result_ok);
9125         return DecodeError_clone(&*owner->contents.err);
9126 }
9127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9128         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9129         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9130         int64_t ret_ref = 0;
9131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9134         ret_ref = (uintptr_t)ret_var.inner;
9135         if (ret_var.is_owned) {
9136                 ret_ref |= 1;
9137         }
9138         return ret_ref;
9139 }
9140
9141 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9142 CHECK(owner->result_ok);
9143         return UpdateFailHTLC_clone(&*owner->contents.result);
9144 }
9145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9146         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9147         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9148         int64_t ret_ref = 0;
9149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9152         ret_ref = (uintptr_t)ret_var.inner;
9153         if (ret_var.is_owned) {
9154                 ret_ref |= 1;
9155         }
9156         return ret_ref;
9157 }
9158
9159 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9160 CHECK(!owner->result_ok);
9161         return DecodeError_clone(&*owner->contents.err);
9162 }
9163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9164         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9165         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9166         int64_t ret_ref = 0;
9167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9170         ret_ref = (uintptr_t)ret_var.inner;
9171         if (ret_var.is_owned) {
9172                 ret_ref |= 1;
9173         }
9174         return ret_ref;
9175 }
9176
9177 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9178 CHECK(owner->result_ok);
9179         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
9180 }
9181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9182         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9183         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9184         int64_t ret_ref = 0;
9185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9188         ret_ref = (uintptr_t)ret_var.inner;
9189         if (ret_var.is_owned) {
9190                 ret_ref |= 1;
9191         }
9192         return ret_ref;
9193 }
9194
9195 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9196 CHECK(!owner->result_ok);
9197         return DecodeError_clone(&*owner->contents.err);
9198 }
9199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9200         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9201         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9202         int64_t ret_ref = 0;
9203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9206         ret_ref = (uintptr_t)ret_var.inner;
9207         if (ret_var.is_owned) {
9208                 ret_ref |= 1;
9209         }
9210         return ret_ref;
9211 }
9212
9213 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9214 CHECK(owner->result_ok);
9215         return UpdateFee_clone(&*owner->contents.result);
9216 }
9217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9218         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9219         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9220         int64_t ret_ref = 0;
9221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9224         ret_ref = (uintptr_t)ret_var.inner;
9225         if (ret_var.is_owned) {
9226                 ret_ref |= 1;
9227         }
9228         return ret_ref;
9229 }
9230
9231 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9232 CHECK(!owner->result_ok);
9233         return DecodeError_clone(&*owner->contents.err);
9234 }
9235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9236         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9237         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9238         int64_t ret_ref = 0;
9239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9242         ret_ref = (uintptr_t)ret_var.inner;
9243         if (ret_var.is_owned) {
9244                 ret_ref |= 1;
9245         }
9246         return ret_ref;
9247 }
9248
9249 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9250 CHECK(owner->result_ok);
9251         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9252 }
9253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9254         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9255         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9256         int64_t ret_ref = 0;
9257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9260         ret_ref = (uintptr_t)ret_var.inner;
9261         if (ret_var.is_owned) {
9262                 ret_ref |= 1;
9263         }
9264         return ret_ref;
9265 }
9266
9267 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9268 CHECK(!owner->result_ok);
9269         return DecodeError_clone(&*owner->contents.err);
9270 }
9271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9272         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9273         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9274         int64_t ret_ref = 0;
9275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9278         ret_ref = (uintptr_t)ret_var.inner;
9279         if (ret_var.is_owned) {
9280                 ret_ref |= 1;
9281         }
9282         return ret_ref;
9283 }
9284
9285 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9286 CHECK(owner->result_ok);
9287         return UpdateAddHTLC_clone(&*owner->contents.result);
9288 }
9289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9290         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9291         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9292         int64_t ret_ref = 0;
9293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9296         ret_ref = (uintptr_t)ret_var.inner;
9297         if (ret_var.is_owned) {
9298                 ret_ref |= 1;
9299         }
9300         return ret_ref;
9301 }
9302
9303 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9304 CHECK(!owner->result_ok);
9305         return DecodeError_clone(&*owner->contents.err);
9306 }
9307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9308         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9309         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9310         int64_t ret_ref = 0;
9311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9314         ret_ref = (uintptr_t)ret_var.inner;
9315         if (ret_var.is_owned) {
9316                 ret_ref |= 1;
9317         }
9318         return ret_ref;
9319 }
9320
9321 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9322 CHECK(owner->result_ok);
9323         return Ping_clone(&*owner->contents.result);
9324 }
9325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9326         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9327         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9328         int64_t ret_ref = 0;
9329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9332         ret_ref = (uintptr_t)ret_var.inner;
9333         if (ret_var.is_owned) {
9334                 ret_ref |= 1;
9335         }
9336         return ret_ref;
9337 }
9338
9339 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9340 CHECK(!owner->result_ok);
9341         return DecodeError_clone(&*owner->contents.err);
9342 }
9343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9344         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9345         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9346         int64_t ret_ref = 0;
9347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9350         ret_ref = (uintptr_t)ret_var.inner;
9351         if (ret_var.is_owned) {
9352                 ret_ref |= 1;
9353         }
9354         return ret_ref;
9355 }
9356
9357 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9358 CHECK(owner->result_ok);
9359         return Pong_clone(&*owner->contents.result);
9360 }
9361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9362         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9363         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9364         int64_t ret_ref = 0;
9365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9368         ret_ref = (uintptr_t)ret_var.inner;
9369         if (ret_var.is_owned) {
9370                 ret_ref |= 1;
9371         }
9372         return ret_ref;
9373 }
9374
9375 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9376 CHECK(!owner->result_ok);
9377         return DecodeError_clone(&*owner->contents.err);
9378 }
9379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9380         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9381         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9382         int64_t ret_ref = 0;
9383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9386         ret_ref = (uintptr_t)ret_var.inner;
9387         if (ret_var.is_owned) {
9388                 ret_ref |= 1;
9389         }
9390         return ret_ref;
9391 }
9392
9393 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9394 CHECK(owner->result_ok);
9395         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9396 }
9397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9398         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9399         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9400         int64_t ret_ref = 0;
9401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9404         ret_ref = (uintptr_t)ret_var.inner;
9405         if (ret_var.is_owned) {
9406                 ret_ref |= 1;
9407         }
9408         return ret_ref;
9409 }
9410
9411 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9412 CHECK(!owner->result_ok);
9413         return DecodeError_clone(&*owner->contents.err);
9414 }
9415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9416         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9417         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9418         int64_t ret_ref = 0;
9419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9422         ret_ref = (uintptr_t)ret_var.inner;
9423         if (ret_var.is_owned) {
9424                 ret_ref |= 1;
9425         }
9426         return ret_ref;
9427 }
9428
9429 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9430 CHECK(owner->result_ok);
9431         return ChannelAnnouncement_clone(&*owner->contents.result);
9432 }
9433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9434         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9435         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9436         int64_t ret_ref = 0;
9437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9440         ret_ref = (uintptr_t)ret_var.inner;
9441         if (ret_var.is_owned) {
9442                 ret_ref |= 1;
9443         }
9444         return ret_ref;
9445 }
9446
9447 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9448 CHECK(!owner->result_ok);
9449         return DecodeError_clone(&*owner->contents.err);
9450 }
9451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9452         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9453         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9454         int64_t ret_ref = 0;
9455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9458         ret_ref = (uintptr_t)ret_var.inner;
9459         if (ret_var.is_owned) {
9460                 ret_ref |= 1;
9461         }
9462         return ret_ref;
9463 }
9464
9465 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9466 CHECK(owner->result_ok);
9467         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9468 }
9469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9470         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9471         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9472         int64_t ret_ref = 0;
9473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9476         ret_ref = (uintptr_t)ret_var.inner;
9477         if (ret_var.is_owned) {
9478                 ret_ref |= 1;
9479         }
9480         return ret_ref;
9481 }
9482
9483 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9484 CHECK(!owner->result_ok);
9485         return DecodeError_clone(&*owner->contents.err);
9486 }
9487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9488         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9489         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9490         int64_t ret_ref = 0;
9491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9494         ret_ref = (uintptr_t)ret_var.inner;
9495         if (ret_var.is_owned) {
9496                 ret_ref |= 1;
9497         }
9498         return ret_ref;
9499 }
9500
9501 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9502 CHECK(owner->result_ok);
9503         return ChannelUpdate_clone(&*owner->contents.result);
9504 }
9505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9506         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9507         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9508         int64_t ret_ref = 0;
9509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9512         ret_ref = (uintptr_t)ret_var.inner;
9513         if (ret_var.is_owned) {
9514                 ret_ref |= 1;
9515         }
9516         return ret_ref;
9517 }
9518
9519 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9520 CHECK(!owner->result_ok);
9521         return DecodeError_clone(&*owner->contents.err);
9522 }
9523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9524         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9525         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9526         int64_t ret_ref = 0;
9527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9530         ret_ref = (uintptr_t)ret_var.inner;
9531         if (ret_var.is_owned) {
9532                 ret_ref |= 1;
9533         }
9534         return ret_ref;
9535 }
9536
9537 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9538 CHECK(owner->result_ok);
9539         return ErrorMessage_clone(&*owner->contents.result);
9540 }
9541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9542         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9543         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9544         int64_t ret_ref = 0;
9545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9548         ret_ref = (uintptr_t)ret_var.inner;
9549         if (ret_var.is_owned) {
9550                 ret_ref |= 1;
9551         }
9552         return ret_ref;
9553 }
9554
9555 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9556 CHECK(!owner->result_ok);
9557         return DecodeError_clone(&*owner->contents.err);
9558 }
9559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9560         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9561         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9562         int64_t ret_ref = 0;
9563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9566         ret_ref = (uintptr_t)ret_var.inner;
9567         if (ret_var.is_owned) {
9568                 ret_ref |= 1;
9569         }
9570         return ret_ref;
9571 }
9572
9573 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9574 CHECK(owner->result_ok);
9575         return WarningMessage_clone(&*owner->contents.result);
9576 }
9577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9578         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9579         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9580         int64_t ret_ref = 0;
9581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9584         ret_ref = (uintptr_t)ret_var.inner;
9585         if (ret_var.is_owned) {
9586                 ret_ref |= 1;
9587         }
9588         return ret_ref;
9589 }
9590
9591 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9592 CHECK(!owner->result_ok);
9593         return DecodeError_clone(&*owner->contents.err);
9594 }
9595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9596         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9597         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9598         int64_t ret_ref = 0;
9599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9602         ret_ref = (uintptr_t)ret_var.inner;
9603         if (ret_var.is_owned) {
9604                 ret_ref |= 1;
9605         }
9606         return ret_ref;
9607 }
9608
9609 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9610 CHECK(owner->result_ok);
9611         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9612 }
9613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9614         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9615         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9616         int64_t ret_ref = 0;
9617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9620         ret_ref = (uintptr_t)ret_var.inner;
9621         if (ret_var.is_owned) {
9622                 ret_ref |= 1;
9623         }
9624         return ret_ref;
9625 }
9626
9627 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9628 CHECK(!owner->result_ok);
9629         return DecodeError_clone(&*owner->contents.err);
9630 }
9631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9632         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9633         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9634         int64_t ret_ref = 0;
9635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9638         ret_ref = (uintptr_t)ret_var.inner;
9639         if (ret_var.is_owned) {
9640                 ret_ref |= 1;
9641         }
9642         return ret_ref;
9643 }
9644
9645 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9646 CHECK(owner->result_ok);
9647         return NodeAnnouncement_clone(&*owner->contents.result);
9648 }
9649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9650         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9651         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9652         int64_t ret_ref = 0;
9653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9656         ret_ref = (uintptr_t)ret_var.inner;
9657         if (ret_var.is_owned) {
9658                 ret_ref |= 1;
9659         }
9660         return ret_ref;
9661 }
9662
9663 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9664 CHECK(!owner->result_ok);
9665         return DecodeError_clone(&*owner->contents.err);
9666 }
9667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9668         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9669         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9670         int64_t ret_ref = 0;
9671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9674         ret_ref = (uintptr_t)ret_var.inner;
9675         if (ret_var.is_owned) {
9676                 ret_ref |= 1;
9677         }
9678         return ret_ref;
9679 }
9680
9681 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9682 CHECK(owner->result_ok);
9683         return QueryShortChannelIds_clone(&*owner->contents.result);
9684 }
9685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9686         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9687         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9688         int64_t ret_ref = 0;
9689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9692         ret_ref = (uintptr_t)ret_var.inner;
9693         if (ret_var.is_owned) {
9694                 ret_ref |= 1;
9695         }
9696         return ret_ref;
9697 }
9698
9699 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9700 CHECK(!owner->result_ok);
9701         return DecodeError_clone(&*owner->contents.err);
9702 }
9703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9704         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9705         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9706         int64_t ret_ref = 0;
9707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9710         ret_ref = (uintptr_t)ret_var.inner;
9711         if (ret_var.is_owned) {
9712                 ret_ref |= 1;
9713         }
9714         return ret_ref;
9715 }
9716
9717 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9718 CHECK(owner->result_ok);
9719         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9720 }
9721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9722         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9723         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9724         int64_t ret_ref = 0;
9725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9728         ret_ref = (uintptr_t)ret_var.inner;
9729         if (ret_var.is_owned) {
9730                 ret_ref |= 1;
9731         }
9732         return ret_ref;
9733 }
9734
9735 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9736 CHECK(!owner->result_ok);
9737         return DecodeError_clone(&*owner->contents.err);
9738 }
9739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9740         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9741         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9742         int64_t ret_ref = 0;
9743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9746         ret_ref = (uintptr_t)ret_var.inner;
9747         if (ret_var.is_owned) {
9748                 ret_ref |= 1;
9749         }
9750         return ret_ref;
9751 }
9752
9753 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9754 CHECK(owner->result_ok);
9755         return QueryChannelRange_clone(&*owner->contents.result);
9756 }
9757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9758         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9759         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9760         int64_t ret_ref = 0;
9761         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9762         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9764         ret_ref = (uintptr_t)ret_var.inner;
9765         if (ret_var.is_owned) {
9766                 ret_ref |= 1;
9767         }
9768         return ret_ref;
9769 }
9770
9771 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9772 CHECK(!owner->result_ok);
9773         return DecodeError_clone(&*owner->contents.err);
9774 }
9775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9776         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9777         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9778         int64_t ret_ref = 0;
9779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9782         ret_ref = (uintptr_t)ret_var.inner;
9783         if (ret_var.is_owned) {
9784                 ret_ref |= 1;
9785         }
9786         return ret_ref;
9787 }
9788
9789 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9790 CHECK(owner->result_ok);
9791         return ReplyChannelRange_clone(&*owner->contents.result);
9792 }
9793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9794         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9795         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9796         int64_t ret_ref = 0;
9797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9800         ret_ref = (uintptr_t)ret_var.inner;
9801         if (ret_var.is_owned) {
9802                 ret_ref |= 1;
9803         }
9804         return ret_ref;
9805 }
9806
9807 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9808 CHECK(!owner->result_ok);
9809         return DecodeError_clone(&*owner->contents.err);
9810 }
9811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9812         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9813         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9814         int64_t ret_ref = 0;
9815         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9816         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9818         ret_ref = (uintptr_t)ret_var.inner;
9819         if (ret_var.is_owned) {
9820                 ret_ref |= 1;
9821         }
9822         return ret_ref;
9823 }
9824
9825 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9826 CHECK(owner->result_ok);
9827         return GossipTimestampFilter_clone(&*owner->contents.result);
9828 }
9829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9830         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9831         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9832         int64_t ret_ref = 0;
9833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9836         ret_ref = (uintptr_t)ret_var.inner;
9837         if (ret_var.is_owned) {
9838                 ret_ref |= 1;
9839         }
9840         return ret_ref;
9841 }
9842
9843 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9844 CHECK(!owner->result_ok);
9845         return DecodeError_clone(&*owner->contents.err);
9846 }
9847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9848         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9849         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9850         int64_t ret_ref = 0;
9851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9854         ret_ref = (uintptr_t)ret_var.inner;
9855         if (ret_var.is_owned) {
9856                 ret_ref |= 1;
9857         }
9858         return ret_ref;
9859 }
9860
9861 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9862         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9863         for (size_t i = 0; i < ret.datalen; i++) {
9864                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9865         }
9866         return ret;
9867 }
9868 static jclass LDKSignOrCreationError_SignError_class = NULL;
9869 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9870 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9871 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9873         LDKSignOrCreationError_SignError_class =
9874                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9875         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9876         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9877         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9878         LDKSignOrCreationError_CreationError_class =
9879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9880         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9881         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9882         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9883 }
9884 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9885         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9886         switch(obj->tag) {
9887                 case LDKSignOrCreationError_SignError: {
9888                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9889                 }
9890                 case LDKSignOrCreationError_CreationError: {
9891                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9892                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9893                 }
9894                 default: abort();
9895         }
9896 }
9897 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9898 CHECK(owner->result_ok);
9899         return Invoice_clone(&*owner->contents.result);
9900 }
9901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9902         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9903         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9904         int64_t ret_ref = 0;
9905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9908         ret_ref = (uintptr_t)ret_var.inner;
9909         if (ret_var.is_owned) {
9910                 ret_ref |= 1;
9911         }
9912         return ret_ref;
9913 }
9914
9915 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9916 CHECK(!owner->result_ok);
9917         return SignOrCreationError_clone(&*owner->contents.err);
9918 }
9919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9920         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9921         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9922         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9923         int64_t ret_ref = (uintptr_t)ret_copy;
9924         return ret_ref;
9925 }
9926
9927 typedef struct LDKFilter_JCalls {
9928         atomic_size_t refcnt;
9929         JavaVM *vm;
9930         jweak o;
9931         jmethodID register_tx_meth;
9932         jmethodID register_output_meth;
9933 } LDKFilter_JCalls;
9934 static void LDKFilter_JCalls_free(void* this_arg) {
9935         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9936         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9937                 JNIEnv *env;
9938                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9939                 if (get_jenv_res == JNI_EDETACHED) {
9940                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9941                 } else {
9942                         DO_ASSERT(get_jenv_res == JNI_OK);
9943                 }
9944                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9945                 if (get_jenv_res == JNI_EDETACHED) {
9946                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9947                 }
9948                 FREE(j_calls);
9949         }
9950 }
9951 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9952         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9953         JNIEnv *env;
9954         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9955         if (get_jenv_res == JNI_EDETACHED) {
9956                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9957         } else {
9958                 DO_ASSERT(get_jenv_res == JNI_OK);
9959         }
9960         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9961         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9962         LDKu8slice script_pubkey_var = script_pubkey;
9963         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9964         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9965         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9966         CHECK(obj != NULL);
9967         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9968         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9969                 (*env)->ExceptionDescribe(env);
9970                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9971         }
9972         if (get_jenv_res == JNI_EDETACHED) {
9973                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9974         }
9975 }
9976 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9977         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9978         JNIEnv *env;
9979         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9980         if (get_jenv_res == JNI_EDETACHED) {
9981                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9982         } else {
9983                 DO_ASSERT(get_jenv_res == JNI_OK);
9984         }
9985         LDKWatchedOutput output_var = output;
9986         int64_t output_ref = 0;
9987         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9988         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9989         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9990         output_ref = (uintptr_t)output_var.inner;
9991         if (output_var.is_owned) {
9992                 output_ref |= 1;
9993         }
9994         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9995         CHECK(obj != NULL);
9996         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9997         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9998                 (*env)->ExceptionDescribe(env);
9999                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10000         }
10001         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10002         CHECK_ACCESS(ret_ptr);
10003         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
10004         FREE((void*)ret);
10005         if (get_jenv_res == JNI_EDETACHED) {
10006                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10007         }
10008         return ret_conv;
10009 }
10010 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10011         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10012         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10013 }
10014 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10015         jclass c = (*env)->GetObjectClass(env, o);
10016         CHECK(c != NULL);
10017         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10018         atomic_init(&calls->refcnt, 1);
10019         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10020         calls->o = (*env)->NewWeakGlobalRef(env, o);
10021         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10022         CHECK(calls->register_tx_meth != NULL);
10023         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
10024         CHECK(calls->register_output_meth != NULL);
10025
10026         LDKFilter ret = {
10027                 .this_arg = (void*) calls,
10028                 .register_tx = register_tx_LDKFilter_jcall,
10029                 .register_output = register_output_LDKFilter_jcall,
10030                 .free = LDKFilter_JCalls_free,
10031         };
10032         return ret;
10033 }
10034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10035         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10036         *res_ptr = LDKFilter_init(env, clz, o);
10037         return (uint64_t)res_ptr;
10038 }
10039 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) {
10040         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10042         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10043         unsigned char txid_arr[32];
10044         CHECK((*env)->GetArrayLength(env, txid) == 32);
10045         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10046         unsigned char (*txid_ref)[32] = &txid_arr;
10047         LDKu8slice script_pubkey_ref;
10048         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10049         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10050         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10051         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10052 }
10053
10054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10055         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10056         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10057         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10058         LDKWatchedOutput output_conv;
10059         output_conv.inner = (void*)(output & (~1));
10060         output_conv.is_owned = (output & 1) || (output == 0);
10061         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10062         output_conv = WatchedOutput_clone(&output_conv);
10063         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10064         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10065         int64_t ret_ref = (uintptr_t)ret_copy;
10066         return ret_ref;
10067 }
10068
10069 static jclass LDKCOption_FilterZ_Some_class = NULL;
10070 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10071 static jclass LDKCOption_FilterZ_None_class = NULL;
10072 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10074         LDKCOption_FilterZ_Some_class =
10075                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10076         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10077         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10078         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10079         LDKCOption_FilterZ_None_class =
10080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10081         CHECK(LDKCOption_FilterZ_None_class != NULL);
10082         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10083         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10084 }
10085 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10086         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
10087         switch(obj->tag) {
10088                 case LDKCOption_FilterZ_Some: {
10089                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10090                         *some_ret = obj->some;
10091                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10092                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10093                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10094                                 LDKFilter_JCalls_cloned(&(*some_ret));
10095                         }
10096                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
10097                 }
10098                 case LDKCOption_FilterZ_None: {
10099                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10100                 }
10101                 default: abort();
10102         }
10103 }
10104 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10105 CHECK(owner->result_ok);
10106         return &*owner->contents.result;
10107 }
10108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10109         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10110         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10111         int64_t ret_ref = 0;
10112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10115         ret_ref = (uintptr_t)ret_var.inner & ~1;
10116         return ret_ref;
10117 }
10118
10119 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10120 CHECK(!owner->result_ok);
10121         return *owner->contents.err;
10122 }
10123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10124         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10125         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10126 }
10127
10128 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10129         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10130         for (size_t i = 0; i < ret.datalen; i++) {
10131                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10132         }
10133         return ret;
10134 }
10135 typedef struct LDKMessageSendEventsProvider_JCalls {
10136         atomic_size_t refcnt;
10137         JavaVM *vm;
10138         jweak o;
10139         jmethodID get_and_clear_pending_msg_events_meth;
10140 } LDKMessageSendEventsProvider_JCalls;
10141 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10142         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10143         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10144                 JNIEnv *env;
10145                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10146                 if (get_jenv_res == JNI_EDETACHED) {
10147                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10148                 } else {
10149                         DO_ASSERT(get_jenv_res == JNI_OK);
10150                 }
10151                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10152                 if (get_jenv_res == JNI_EDETACHED) {
10153                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10154                 }
10155                 FREE(j_calls);
10156         }
10157 }
10158 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10159         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10160         JNIEnv *env;
10161         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10162         if (get_jenv_res == JNI_EDETACHED) {
10163                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10164         } else {
10165                 DO_ASSERT(get_jenv_res == JNI_OK);
10166         }
10167         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10168         CHECK(obj != NULL);
10169         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10170         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10171                 (*env)->ExceptionDescribe(env);
10172                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10173         }
10174         LDKCVec_MessageSendEventZ ret_constr;
10175         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10176         if (ret_constr.datalen > 0)
10177                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10178         else
10179                 ret_constr.data = NULL;
10180         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10181         for (size_t s = 0; s < ret_constr.datalen; s++) {
10182                 int64_t ret_conv_18 = ret_vals[s];
10183                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
10184                 CHECK_ACCESS(ret_conv_18_ptr);
10185                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10186                 FREE((void*)ret_conv_18);
10187                 ret_constr.data[s] = ret_conv_18_conv;
10188         }
10189         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10190         if (get_jenv_res == JNI_EDETACHED) {
10191                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10192         }
10193         return ret_constr;
10194 }
10195 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10196         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10197         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10198 }
10199 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10200         jclass c = (*env)->GetObjectClass(env, o);
10201         CHECK(c != NULL);
10202         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10203         atomic_init(&calls->refcnt, 1);
10204         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10205         calls->o = (*env)->NewWeakGlobalRef(env, o);
10206         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10207         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10208
10209         LDKMessageSendEventsProvider ret = {
10210                 .this_arg = (void*) calls,
10211                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10212                 .free = LDKMessageSendEventsProvider_JCalls_free,
10213         };
10214         return ret;
10215 }
10216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10217         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10218         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10219         return (uint64_t)res_ptr;
10220 }
10221 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10222         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10224         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10225         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10226         int64_tArray ret_arr = NULL;
10227         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10228         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10229         for (size_t s = 0; s < ret_var.datalen; s++) {
10230                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10231                 *ret_conv_18_copy = ret_var.data[s];
10232                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10233                 ret_arr_ptr[s] = ret_conv_18_ref;
10234         }
10235         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10236         FREE(ret_var.data);
10237         return ret_arr;
10238 }
10239
10240 typedef struct LDKEventHandler_JCalls {
10241         atomic_size_t refcnt;
10242         JavaVM *vm;
10243         jweak o;
10244         jmethodID handle_event_meth;
10245 } LDKEventHandler_JCalls;
10246 static void LDKEventHandler_JCalls_free(void* this_arg) {
10247         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10248         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10249                 JNIEnv *env;
10250                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10251                 if (get_jenv_res == JNI_EDETACHED) {
10252                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10253                 } else {
10254                         DO_ASSERT(get_jenv_res == JNI_OK);
10255                 }
10256                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10257                 if (get_jenv_res == JNI_EDETACHED) {
10258                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10259                 }
10260                 FREE(j_calls);
10261         }
10262 }
10263 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10264         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10265         JNIEnv *env;
10266         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10267         if (get_jenv_res == JNI_EDETACHED) {
10268                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10269         } else {
10270                 DO_ASSERT(get_jenv_res == JNI_OK);
10271         }
10272         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10273         *ret_event = Event_clone(event);
10274         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10275         CHECK(obj != NULL);
10276         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10277         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10278                 (*env)->ExceptionDescribe(env);
10279                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10280         }
10281         if (get_jenv_res == JNI_EDETACHED) {
10282                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10283         }
10284 }
10285 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10286         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10287         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10288 }
10289 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10290         jclass c = (*env)->GetObjectClass(env, o);
10291         CHECK(c != NULL);
10292         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10293         atomic_init(&calls->refcnt, 1);
10294         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10295         calls->o = (*env)->NewWeakGlobalRef(env, o);
10296         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10297         CHECK(calls->handle_event_meth != NULL);
10298
10299         LDKEventHandler ret = {
10300                 .this_arg = (void*) calls,
10301                 .handle_event = handle_event_LDKEventHandler_jcall,
10302                 .free = LDKEventHandler_JCalls_free,
10303         };
10304         return ret;
10305 }
10306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10307         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10308         *res_ptr = LDKEventHandler_init(env, clz, o);
10309         return (uint64_t)res_ptr;
10310 }
10311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10312         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10313         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10314         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10315         LDKEvent* event_conv = (LDKEvent*)event;
10316         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10317 }
10318
10319 typedef struct LDKEventsProvider_JCalls {
10320         atomic_size_t refcnt;
10321         JavaVM *vm;
10322         jweak o;
10323         jmethodID process_pending_events_meth;
10324 } LDKEventsProvider_JCalls;
10325 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10326         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10327         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10328                 JNIEnv *env;
10329                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10330                 if (get_jenv_res == JNI_EDETACHED) {
10331                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10332                 } else {
10333                         DO_ASSERT(get_jenv_res == JNI_OK);
10334                 }
10335                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10336                 if (get_jenv_res == JNI_EDETACHED) {
10337                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10338                 }
10339                 FREE(j_calls);
10340         }
10341 }
10342 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10343         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
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         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10352         *handler_ret = handler;
10353         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10354         CHECK(obj != NULL);
10355         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10356         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10357                 (*env)->ExceptionDescribe(env);
10358                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10359         }
10360         if (get_jenv_res == JNI_EDETACHED) {
10361                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10362         }
10363 }
10364 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10365         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10366         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10367 }
10368 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10369         jclass c = (*env)->GetObjectClass(env, o);
10370         CHECK(c != NULL);
10371         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10372         atomic_init(&calls->refcnt, 1);
10373         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10374         calls->o = (*env)->NewWeakGlobalRef(env, o);
10375         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10376         CHECK(calls->process_pending_events_meth != NULL);
10377
10378         LDKEventsProvider ret = {
10379                 .this_arg = (void*) calls,
10380                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10381                 .free = LDKEventsProvider_JCalls_free,
10382         };
10383         return ret;
10384 }
10385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10386         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10387         *res_ptr = LDKEventsProvider_init(env, clz, o);
10388         return (uint64_t)res_ptr;
10389 }
10390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10391         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10392         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10393         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10394         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10395         CHECK_ACCESS(handler_ptr);
10396         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10397         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10399                 LDKEventHandler_JCalls_cloned(&handler_conv);
10400         }
10401         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10402 }
10403
10404 typedef struct LDKScore_JCalls {
10405         atomic_size_t refcnt;
10406         JavaVM *vm;
10407         jweak o;
10408         jmethodID channel_penalty_msat_meth;
10409         jmethodID payment_path_failed_meth;
10410         jmethodID payment_path_successful_meth;
10411         jmethodID write_meth;
10412 } LDKScore_JCalls;
10413 static void LDKScore_JCalls_free(void* this_arg) {
10414         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10415         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10424                 if (get_jenv_res == JNI_EDETACHED) {
10425                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10426                 }
10427                 FREE(j_calls);
10428         }
10429 }
10430 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
10431         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10432         JNIEnv *env;
10433         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10434         if (get_jenv_res == JNI_EDETACHED) {
10435                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10436         } else {
10437                 DO_ASSERT(get_jenv_res == JNI_OK);
10438         }
10439         int64_t short_channel_id_conv = short_channel_id;
10440         LDKNodeId source_var = *source;
10441         int64_t source_ref = 0;
10442         source_var = NodeId_clone(&source_var);
10443         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10444         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10445         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10446         source_ref = (uintptr_t)source_var.inner;
10447         if (source_var.is_owned) {
10448                 source_ref |= 1;
10449         }
10450         LDKNodeId target_var = *target;
10451         int64_t target_ref = 0;
10452         target_var = NodeId_clone(&target_var);
10453         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10454         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10455         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10456         target_ref = (uintptr_t)target_var.inner;
10457         if (target_var.is_owned) {
10458                 target_ref |= 1;
10459         }
10460         LDKChannelUsage usage_var = usage;
10461         int64_t usage_ref = 0;
10462         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10463         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10464         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
10465         usage_ref = (uintptr_t)usage_var.inner;
10466         if (usage_var.is_owned) {
10467                 usage_ref |= 1;
10468         }
10469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10470         CHECK(obj != NULL);
10471         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
10472         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10473                 (*env)->ExceptionDescribe(env);
10474                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10475         }
10476         if (get_jenv_res == JNI_EDETACHED) {
10477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10478         }
10479         return ret;
10480 }
10481 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10482         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10483         JNIEnv *env;
10484         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10485         if (get_jenv_res == JNI_EDETACHED) {
10486                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10487         } else {
10488                 DO_ASSERT(get_jenv_res == JNI_OK);
10489         }
10490         LDKCVec_RouteHopZ path_var = path;
10491         int64_tArray path_arr = NULL;
10492         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10493         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10494         for (size_t k = 0; k < path_var.datalen; k++) {
10495                 LDKRouteHop path_conv_10_var = path_var.data[k];
10496                 int64_t path_conv_10_ref = 0;
10497                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10498                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10499                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10500                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10501                 if (path_conv_10_var.is_owned) {
10502                         path_conv_10_ref |= 1;
10503                 }
10504                 path_arr_ptr[k] = path_conv_10_ref;
10505         }
10506         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10507         FREE(path_var.data);
10508         int64_t short_channel_id_conv = short_channel_id;
10509         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10510         CHECK(obj != NULL);
10511         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
10512         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10513                 (*env)->ExceptionDescribe(env);
10514                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10515         }
10516         if (get_jenv_res == JNI_EDETACHED) {
10517                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10518         }
10519 }
10520 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10521         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10522         JNIEnv *env;
10523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10524         if (get_jenv_res == JNI_EDETACHED) {
10525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10526         } else {
10527                 DO_ASSERT(get_jenv_res == JNI_OK);
10528         }
10529         LDKCVec_RouteHopZ path_var = path;
10530         int64_tArray path_arr = NULL;
10531         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10532         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10533         for (size_t k = 0; k < path_var.datalen; k++) {
10534                 LDKRouteHop path_conv_10_var = path_var.data[k];
10535                 int64_t path_conv_10_ref = 0;
10536                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10537                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10538                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10539                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10540                 if (path_conv_10_var.is_owned) {
10541                         path_conv_10_ref |= 1;
10542                 }
10543                 path_arr_ptr[k] = path_conv_10_ref;
10544         }
10545         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10546         FREE(path_var.data);
10547         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10548         CHECK(obj != NULL);
10549         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10550         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10551                 (*env)->ExceptionDescribe(env);
10552                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
10553         }
10554         if (get_jenv_res == JNI_EDETACHED) {
10555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10556         }
10557 }
10558 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10559         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10560         JNIEnv *env;
10561         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10562         if (get_jenv_res == JNI_EDETACHED) {
10563                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10564         } else {
10565                 DO_ASSERT(get_jenv_res == JNI_OK);
10566         }
10567         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10568         CHECK(obj != NULL);
10569         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10570         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10571                 (*env)->ExceptionDescribe(env);
10572                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10573         }
10574         LDKCVec_u8Z ret_ref;
10575         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10576         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10577         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10578         if (get_jenv_res == JNI_EDETACHED) {
10579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10580         }
10581         return ret_ref;
10582 }
10583 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10584         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10586 }
10587 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10588         jclass c = (*env)->GetObjectClass(env, o);
10589         CHECK(c != NULL);
10590         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10591         atomic_init(&calls->refcnt, 1);
10592         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10593         calls->o = (*env)->NewWeakGlobalRef(env, o);
10594         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
10595         CHECK(calls->channel_penalty_msat_meth != NULL);
10596         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10597         CHECK(calls->payment_path_failed_meth != NULL);
10598         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10599         CHECK(calls->payment_path_successful_meth != NULL);
10600         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10601         CHECK(calls->write_meth != NULL);
10602
10603         LDKScore ret = {
10604                 .this_arg = (void*) calls,
10605                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10606                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10607                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10608                 .write = write_LDKScore_jcall,
10609                 .free = LDKScore_JCalls_free,
10610         };
10611         return ret;
10612 }
10613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10614         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10615         *res_ptr = LDKScore_init(env, clz, o);
10616         return (uint64_t)res_ptr;
10617 }
10618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target, int64_t usage) {
10619         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10620         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10621         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10622         LDKNodeId source_conv;
10623         source_conv.inner = (void*)(source & (~1));
10624         source_conv.is_owned = false;
10625         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10626         LDKNodeId target_conv;
10627         target_conv.inner = (void*)(target & (~1));
10628         target_conv.is_owned = false;
10629         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10630         LDKChannelUsage usage_conv;
10631         usage_conv.inner = (void*)(usage & (~1));
10632         usage_conv.is_owned = (usage & 1) || (usage == 0);
10633         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
10634         usage_conv = ChannelUsage_clone(&usage_conv);
10635         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
10636         return ret_conv;
10637 }
10638
10639 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) {
10640         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10641         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10642         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10643         LDKCVec_RouteHopZ path_constr;
10644         path_constr.datalen = (*env)->GetArrayLength(env, path);
10645         if (path_constr.datalen > 0)
10646                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10647         else
10648                 path_constr.data = NULL;
10649         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10650         for (size_t k = 0; k < path_constr.datalen; k++) {
10651                 int64_t path_conv_10 = path_vals[k];
10652                 LDKRouteHop path_conv_10_conv;
10653                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10654                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10655                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10656                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10657                 path_constr.data[k] = path_conv_10_conv;
10658         }
10659         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10660         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10661 }
10662
10663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10664         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10665         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10666         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10667         LDKCVec_RouteHopZ path_constr;
10668         path_constr.datalen = (*env)->GetArrayLength(env, path);
10669         if (path_constr.datalen > 0)
10670                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10671         else
10672                 path_constr.data = NULL;
10673         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10674         for (size_t k = 0; k < path_constr.datalen; k++) {
10675                 int64_t path_conv_10 = path_vals[k];
10676                 LDKRouteHop path_conv_10_conv;
10677                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10678                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10679                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10680                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10681                 path_constr.data[k] = path_conv_10_conv;
10682         }
10683         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10684         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10685 }
10686
10687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10688         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10689         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10690         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10691         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10692         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10693         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10694         CVec_u8Z_free(ret_var);
10695         return ret_arr;
10696 }
10697
10698 typedef struct LDKPersister_JCalls {
10699         atomic_size_t refcnt;
10700         JavaVM *vm;
10701         jweak o;
10702         jmethodID persist_manager_meth;
10703         jmethodID persist_graph_meth;
10704         jmethodID persist_scorer_meth;
10705 } LDKPersister_JCalls;
10706 static void LDKPersister_JCalls_free(void* this_arg) {
10707         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10708         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10709                 JNIEnv *env;
10710                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10711                 if (get_jenv_res == JNI_EDETACHED) {
10712                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10713                 } else {
10714                         DO_ASSERT(get_jenv_res == JNI_OK);
10715                 }
10716                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10717                 if (get_jenv_res == JNI_EDETACHED) {
10718                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10719                 }
10720                 FREE(j_calls);
10721         }
10722 }
10723 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10724         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10725         JNIEnv *env;
10726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10727         if (get_jenv_res == JNI_EDETACHED) {
10728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10729         } else {
10730                 DO_ASSERT(get_jenv_res == JNI_OK);
10731         }
10732         LDKChannelManager channel_manager_var = *channel_manager;
10733         int64_t channel_manager_ref = 0;
10734         // WARNING: we may need a move here but no clone is available for LDKChannelManager
10735         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10736         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10737         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10738         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
10739         if (channel_manager_var.is_owned) {
10740                 channel_manager_ref |= 1;
10741         }
10742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10743         CHECK(obj != NULL);
10744         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10746                 (*env)->ExceptionDescribe(env);
10747                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
10748         }
10749         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10750         CHECK_ACCESS(ret_ptr);
10751         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10752         FREE((void*)ret);
10753         if (get_jenv_res == JNI_EDETACHED) {
10754                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10755         }
10756         return ret_conv;
10757 }
10758 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
10759         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10760         JNIEnv *env;
10761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10762         if (get_jenv_res == JNI_EDETACHED) {
10763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10764         } else {
10765                 DO_ASSERT(get_jenv_res == JNI_OK);
10766         }
10767         LDKNetworkGraph network_graph_var = *network_graph;
10768         int64_t network_graph_ref = 0;
10769         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
10770         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10771         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10772         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
10773         network_graph_ref = (uintptr_t)network_graph_var.inner;
10774         if (network_graph_var.is_owned) {
10775                 network_graph_ref |= 1;
10776         }
10777         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10778         CHECK(obj != NULL);
10779         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
10780         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10781                 (*env)->ExceptionDescribe(env);
10782                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
10783         }
10784         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10785         CHECK_ACCESS(ret_ptr);
10786         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10787         FREE((void*)ret);
10788         if (get_jenv_res == JNI_EDETACHED) {
10789                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10790         }
10791         return ret_conv;
10792 }
10793 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
10794         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10795         JNIEnv *env;
10796         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10797         if (get_jenv_res == JNI_EDETACHED) {
10798                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10799         } else {
10800                 DO_ASSERT(get_jenv_res == JNI_OK);
10801         }
10802         LDKMultiThreadedLockableScore scorer_var = *scorer;
10803         int64_t scorer_ref = 0;
10804         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
10805         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10806         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10807         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
10808         scorer_ref = (uintptr_t)scorer_var.inner;
10809         if (scorer_var.is_owned) {
10810                 scorer_ref |= 1;
10811         }
10812         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10813         CHECK(obj != NULL);
10814         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
10815         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10816                 (*env)->ExceptionDescribe(env);
10817                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
10818         }
10819         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10820         CHECK_ACCESS(ret_ptr);
10821         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10822         FREE((void*)ret);
10823         if (get_jenv_res == JNI_EDETACHED) {
10824                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10825         }
10826         return ret_conv;
10827 }
10828 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
10829         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
10830         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10831 }
10832 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
10833         jclass c = (*env)->GetObjectClass(env, o);
10834         CHECK(c != NULL);
10835         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
10836         atomic_init(&calls->refcnt, 1);
10837         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10838         calls->o = (*env)->NewWeakGlobalRef(env, o);
10839         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10840         CHECK(calls->persist_manager_meth != NULL);
10841         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
10842         CHECK(calls->persist_graph_meth != NULL);
10843         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
10844         CHECK(calls->persist_scorer_meth != NULL);
10845
10846         LDKPersister ret = {
10847                 .this_arg = (void*) calls,
10848                 .persist_manager = persist_manager_LDKPersister_jcall,
10849                 .persist_graph = persist_graph_LDKPersister_jcall,
10850                 .persist_scorer = persist_scorer_LDKPersister_jcall,
10851                 .free = LDKPersister_JCalls_free,
10852         };
10853         return ret;
10854 }
10855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10856         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
10857         *res_ptr = LDKPersister_init(env, clz, o);
10858         return (uint64_t)res_ptr;
10859 }
10860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10861         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10862         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10863         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10864         LDKChannelManager channel_manager_conv;
10865         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10866         channel_manager_conv.is_owned = false;
10867         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10868         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10869         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10870         return (int64_t)ret_conv;
10871 }
10872
10873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
10874         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10875         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10876         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10877         LDKNetworkGraph network_graph_conv;
10878         network_graph_conv.inner = (void*)(network_graph & (~1));
10879         network_graph_conv.is_owned = false;
10880         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
10881         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10882         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
10883         return (int64_t)ret_conv;
10884 }
10885
10886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
10887         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10888         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10889         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10890         LDKMultiThreadedLockableScore scorer_conv;
10891         scorer_conv.inner = (void*)(scorer & (~1));
10892         scorer_conv.is_owned = false;
10893         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
10894         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10895         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
10896         return (int64_t)ret_conv;
10897 }
10898
10899 typedef struct LDKListen_JCalls {
10900         atomic_size_t refcnt;
10901         JavaVM *vm;
10902         jweak o;
10903         jmethodID filtered_block_connected_meth;
10904         jmethodID block_connected_meth;
10905         jmethodID block_disconnected_meth;
10906 } LDKListen_JCalls;
10907 static void LDKListen_JCalls_free(void* this_arg) {
10908         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10909         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10910                 JNIEnv *env;
10911                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10912                 if (get_jenv_res == JNI_EDETACHED) {
10913                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10914                 } else {
10915                         DO_ASSERT(get_jenv_res == JNI_OK);
10916                 }
10917                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10918                 if (get_jenv_res == JNI_EDETACHED) {
10919                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10920                 }
10921                 FREE(j_calls);
10922         }
10923 }
10924 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10925         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10926         JNIEnv *env;
10927         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10928         if (get_jenv_res == JNI_EDETACHED) {
10929                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10930         } else {
10931                 DO_ASSERT(get_jenv_res == JNI_OK);
10932         }
10933         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10934         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10935         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10936         int64_tArray txdata_arr = NULL;
10937         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10938         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10939         for (size_t c = 0; c < txdata_var.datalen; c++) {
10940                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10941                 *txdata_conv_28_conv = txdata_var.data[c];
10942                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10943         }
10944         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10945         FREE(txdata_var.data);
10946         int32_t height_conv = height;
10947         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10948         CHECK(obj != NULL);
10949         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
10950         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10951                 (*env)->ExceptionDescribe(env);
10952                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
10953         }
10954         if (get_jenv_res == JNI_EDETACHED) {
10955                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10956         }
10957 }
10958 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10959         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10960         JNIEnv *env;
10961         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10962         if (get_jenv_res == JNI_EDETACHED) {
10963                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10964         } else {
10965                 DO_ASSERT(get_jenv_res == JNI_OK);
10966         }
10967         LDKu8slice block_var = block;
10968         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10969         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10970         int32_t height_conv = height;
10971         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10972         CHECK(obj != NULL);
10973         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
10974         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10975                 (*env)->ExceptionDescribe(env);
10976                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10977         }
10978         if (get_jenv_res == JNI_EDETACHED) {
10979                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10980         }
10981 }
10982 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10983         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10984         JNIEnv *env;
10985         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10986         if (get_jenv_res == JNI_EDETACHED) {
10987                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10988         } else {
10989                 DO_ASSERT(get_jenv_res == JNI_OK);
10990         }
10991         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10992         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10993         int32_t height_conv = height;
10994         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10995         CHECK(obj != NULL);
10996         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
10997         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10998                 (*env)->ExceptionDescribe(env);
10999                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11000         }
11001         if (get_jenv_res == JNI_EDETACHED) {
11002                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11003         }
11004 }
11005 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11006         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11007         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11008 }
11009 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11010         jclass c = (*env)->GetObjectClass(env, o);
11011         CHECK(c != NULL);
11012         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11013         atomic_init(&calls->refcnt, 1);
11014         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11015         calls->o = (*env)->NewWeakGlobalRef(env, o);
11016         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11017         CHECK(calls->filtered_block_connected_meth != NULL);
11018         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11019         CHECK(calls->block_connected_meth != NULL);
11020         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11021         CHECK(calls->block_disconnected_meth != NULL);
11022
11023         LDKListen ret = {
11024                 .this_arg = (void*) calls,
11025                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11026                 .block_connected = block_connected_LDKListen_jcall,
11027                 .block_disconnected = block_disconnected_LDKListen_jcall,
11028                 .free = LDKListen_JCalls_free,
11029         };
11030         return ret;
11031 }
11032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11033         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11034         *res_ptr = LDKListen_init(env, clz, o);
11035         return (uint64_t)res_ptr;
11036 }
11037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1filtered_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11038         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11039         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11040         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11041         unsigned char header_arr[80];
11042         CHECK((*env)->GetArrayLength(env, header) == 80);
11043         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11044         unsigned char (*header_ref)[80] = &header_arr;
11045         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11046         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11047         if (txdata_constr.datalen > 0)
11048                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11049         else
11050                 txdata_constr.data = NULL;
11051         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11052         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11053                 int64_t txdata_conv_28 = txdata_vals[c];
11054                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11055                 CHECK_ACCESS(txdata_conv_28_ptr);
11056                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11057                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11058                 txdata_constr.data[c] = txdata_conv_28_conv;
11059         }
11060         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11061         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11062 }
11063
11064 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) {
11065         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11066         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11067         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11068         LDKu8slice block_ref;
11069         block_ref.datalen = (*env)->GetArrayLength(env, block);
11070         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11071         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11072         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11073 }
11074
11075 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) {
11076         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11077         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11078         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11079         unsigned char header_arr[80];
11080         CHECK((*env)->GetArrayLength(env, header) == 80);
11081         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11082         unsigned char (*header_ref)[80] = &header_arr;
11083         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11084 }
11085
11086 typedef struct LDKConfirm_JCalls {
11087         atomic_size_t refcnt;
11088         JavaVM *vm;
11089         jweak o;
11090         jmethodID transactions_confirmed_meth;
11091         jmethodID transaction_unconfirmed_meth;
11092         jmethodID best_block_updated_meth;
11093         jmethodID get_relevant_txids_meth;
11094 } LDKConfirm_JCalls;
11095 static void LDKConfirm_JCalls_free(void* this_arg) {
11096         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11097         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11098                 JNIEnv *env;
11099                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11100                 if (get_jenv_res == JNI_EDETACHED) {
11101                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11102                 } else {
11103                         DO_ASSERT(get_jenv_res == JNI_OK);
11104                 }
11105                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11106                 if (get_jenv_res == JNI_EDETACHED) {
11107                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11108                 }
11109                 FREE(j_calls);
11110         }
11111 }
11112 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11113         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11114         JNIEnv *env;
11115         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11116         if (get_jenv_res == JNI_EDETACHED) {
11117                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11118         } else {
11119                 DO_ASSERT(get_jenv_res == JNI_OK);
11120         }
11121         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11122         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11123         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11124         int64_tArray txdata_arr = NULL;
11125         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11126         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11127         for (size_t c = 0; c < txdata_var.datalen; c++) {
11128                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11129                 *txdata_conv_28_conv = txdata_var.data[c];
11130                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11131         }
11132         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11133         FREE(txdata_var.data);
11134         int32_t height_conv = height;
11135         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11136         CHECK(obj != NULL);
11137         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11138         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11139                 (*env)->ExceptionDescribe(env);
11140                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11141         }
11142         if (get_jenv_res == JNI_EDETACHED) {
11143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11144         }
11145 }
11146 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11147         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11148         JNIEnv *env;
11149         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11150         if (get_jenv_res == JNI_EDETACHED) {
11151                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11152         } else {
11153                 DO_ASSERT(get_jenv_res == JNI_OK);
11154         }
11155         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11156         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11157         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11158         CHECK(obj != NULL);
11159         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11161                 (*env)->ExceptionDescribe(env);
11162                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11163         }
11164         if (get_jenv_res == JNI_EDETACHED) {
11165                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11166         }
11167 }
11168 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11169         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11170         JNIEnv *env;
11171         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11172         if (get_jenv_res == JNI_EDETACHED) {
11173                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11174         } else {
11175                 DO_ASSERT(get_jenv_res == JNI_OK);
11176         }
11177         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11178         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11179         int32_t height_conv = height;
11180         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11181         CHECK(obj != NULL);
11182         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11183         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11184                 (*env)->ExceptionDescribe(env);
11185                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11186         }
11187         if (get_jenv_res == JNI_EDETACHED) {
11188                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11189         }
11190 }
11191 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11192         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11193         JNIEnv *env;
11194         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11195         if (get_jenv_res == JNI_EDETACHED) {
11196                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11197         } else {
11198                 DO_ASSERT(get_jenv_res == JNI_OK);
11199         }
11200         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11201         CHECK(obj != NULL);
11202         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11203         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11204                 (*env)->ExceptionDescribe(env);
11205                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11206         }
11207         LDKCVec_TxidZ ret_constr;
11208         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11209         if (ret_constr.datalen > 0)
11210                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11211         else
11212                 ret_constr.data = NULL;
11213         for (size_t i = 0; i < ret_constr.datalen; i++) {
11214                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11215                 LDKThirtyTwoBytes ret_conv_8_ref;
11216                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11217                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11218                 ret_constr.data[i] = ret_conv_8_ref;
11219         }
11220         if (get_jenv_res == JNI_EDETACHED) {
11221                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11222         }
11223         return ret_constr;
11224 }
11225 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11226         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11227         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11228 }
11229 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11230         jclass c = (*env)->GetObjectClass(env, o);
11231         CHECK(c != NULL);
11232         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11233         atomic_init(&calls->refcnt, 1);
11234         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11235         calls->o = (*env)->NewWeakGlobalRef(env, o);
11236         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11237         CHECK(calls->transactions_confirmed_meth != NULL);
11238         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11239         CHECK(calls->transaction_unconfirmed_meth != NULL);
11240         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11241         CHECK(calls->best_block_updated_meth != NULL);
11242         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11243         CHECK(calls->get_relevant_txids_meth != NULL);
11244
11245         LDKConfirm ret = {
11246                 .this_arg = (void*) calls,
11247                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11248                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11249                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11250                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11251                 .free = LDKConfirm_JCalls_free,
11252         };
11253         return ret;
11254 }
11255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11256         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11257         *res_ptr = LDKConfirm_init(env, clz, o);
11258         return (uint64_t)res_ptr;
11259 }
11260 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) {
11261         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11262         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11263         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11264         unsigned char header_arr[80];
11265         CHECK((*env)->GetArrayLength(env, header) == 80);
11266         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11267         unsigned char (*header_ref)[80] = &header_arr;
11268         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11269         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11270         if (txdata_constr.datalen > 0)
11271                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11272         else
11273                 txdata_constr.data = NULL;
11274         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11275         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11276                 int64_t txdata_conv_28 = txdata_vals[c];
11277                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11278                 CHECK_ACCESS(txdata_conv_28_ptr);
11279                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11280                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11281                 txdata_constr.data[c] = txdata_conv_28_conv;
11282         }
11283         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11284         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11285 }
11286
11287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11288         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11289         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11290         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11291         unsigned char txid_arr[32];
11292         CHECK((*env)->GetArrayLength(env, txid) == 32);
11293         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11294         unsigned char (*txid_ref)[32] = &txid_arr;
11295         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11296 }
11297
11298 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) {
11299         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11301         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11302         unsigned char header_arr[80];
11303         CHECK((*env)->GetArrayLength(env, header) == 80);
11304         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11305         unsigned char (*header_ref)[80] = &header_arr;
11306         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11307 }
11308
11309 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11310         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11311         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11312         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11313         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11314         jobjectArray ret_arr = NULL;
11315         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11316         ;
11317         for (size_t i = 0; i < ret_var.datalen; i++) {
11318                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11319                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11320                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11321         }
11322         
11323         FREE(ret_var.data);
11324         return ret_arr;
11325 }
11326
11327 typedef struct LDKPersist_JCalls {
11328         atomic_size_t refcnt;
11329         JavaVM *vm;
11330         jweak o;
11331         jmethodID persist_new_channel_meth;
11332         jmethodID update_persisted_channel_meth;
11333 } LDKPersist_JCalls;
11334 static void LDKPersist_JCalls_free(void* this_arg) {
11335         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11336         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11337                 JNIEnv *env;
11338                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11339                 if (get_jenv_res == JNI_EDETACHED) {
11340                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11341                 } else {
11342                         DO_ASSERT(get_jenv_res == JNI_OK);
11343                 }
11344                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11345                 if (get_jenv_res == JNI_EDETACHED) {
11346                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11347                 }
11348                 FREE(j_calls);
11349         }
11350 }
11351 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11352         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11353         JNIEnv *env;
11354         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11355         if (get_jenv_res == JNI_EDETACHED) {
11356                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11357         } else {
11358                 DO_ASSERT(get_jenv_res == JNI_OK);
11359         }
11360         LDKOutPoint channel_id_var = channel_id;
11361         int64_t channel_id_ref = 0;
11362         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11363         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11364         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11365         channel_id_ref = (uintptr_t)channel_id_var.inner;
11366         if (channel_id_var.is_owned) {
11367                 channel_id_ref |= 1;
11368         }
11369         LDKChannelMonitor data_var = *data;
11370         int64_t data_ref = 0;
11371         data_var = ChannelMonitor_clone(&data_var);
11372         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11373         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11374         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11375         data_ref = (uintptr_t)data_var.inner;
11376         if (data_var.is_owned) {
11377                 data_ref |= 1;
11378         }
11379         LDKMonitorUpdateId update_id_var = update_id;
11380         int64_t update_id_ref = 0;
11381         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11382         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11383         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11384         update_id_ref = (uintptr_t)update_id_var.inner;
11385         if (update_id_var.is_owned) {
11386                 update_id_ref |= 1;
11387         }
11388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11389         CHECK(obj != NULL);
11390         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11391         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11392                 (*env)->ExceptionDescribe(env);
11393                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11394         }
11395         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11396         CHECK_ACCESS(ret_ptr);
11397         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11398         FREE((void*)ret);
11399         if (get_jenv_res == JNI_EDETACHED) {
11400                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11401         }
11402         return ret_conv;
11403 }
11404 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11405         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11406         JNIEnv *env;
11407         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11408         if (get_jenv_res == JNI_EDETACHED) {
11409                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11410         } else {
11411                 DO_ASSERT(get_jenv_res == JNI_OK);
11412         }
11413         LDKOutPoint channel_id_var = channel_id;
11414         int64_t channel_id_ref = 0;
11415         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11416         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11417         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11418         channel_id_ref = (uintptr_t)channel_id_var.inner;
11419         if (channel_id_var.is_owned) {
11420                 channel_id_ref |= 1;
11421         }
11422         LDKChannelMonitorUpdate update_var = *update;
11423         int64_t update_ref = 0;
11424         if ((uintptr_t)update_var.inner > 4096) {
11425                 update_var = ChannelMonitorUpdate_clone(&update_var);
11426                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11427                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11428         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11429                 update_ref = (uintptr_t)update_var.inner;
11430                 if (update_var.is_owned) {
11431                         update_ref |= 1;
11432                 }
11433         }
11434         LDKChannelMonitor data_var = *data;
11435         int64_t data_ref = 0;
11436         data_var = ChannelMonitor_clone(&data_var);
11437         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11438         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11439         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11440         data_ref = (uintptr_t)data_var.inner;
11441         if (data_var.is_owned) {
11442                 data_ref |= 1;
11443         }
11444         LDKMonitorUpdateId update_id_var = update_id;
11445         int64_t update_id_ref = 0;
11446         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11447         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11448         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11449         update_id_ref = (uintptr_t)update_id_var.inner;
11450         if (update_id_var.is_owned) {
11451                 update_id_ref |= 1;
11452         }
11453         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11454         CHECK(obj != NULL);
11455         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11456         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11457                 (*env)->ExceptionDescribe(env);
11458                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11459         }
11460         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11461         CHECK_ACCESS(ret_ptr);
11462         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11463         FREE((void*)ret);
11464         if (get_jenv_res == JNI_EDETACHED) {
11465                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11466         }
11467         return ret_conv;
11468 }
11469 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11470         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11471         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11472 }
11473 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11474         jclass c = (*env)->GetObjectClass(env, o);
11475         CHECK(c != NULL);
11476         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11477         atomic_init(&calls->refcnt, 1);
11478         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11479         calls->o = (*env)->NewWeakGlobalRef(env, o);
11480         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11481         CHECK(calls->persist_new_channel_meth != NULL);
11482         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11483         CHECK(calls->update_persisted_channel_meth != NULL);
11484
11485         LDKPersist ret = {
11486                 .this_arg = (void*) calls,
11487                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11488                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11489                 .free = LDKPersist_JCalls_free,
11490         };
11491         return ret;
11492 }
11493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11494         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11495         *res_ptr = LDKPersist_init(env, clz, o);
11496         return (uint64_t)res_ptr;
11497 }
11498 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) {
11499         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11500         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11501         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11502         LDKOutPoint channel_id_conv;
11503         channel_id_conv.inner = (void*)(channel_id & (~1));
11504         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11505         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11506         channel_id_conv = OutPoint_clone(&channel_id_conv);
11507         LDKChannelMonitor data_conv;
11508         data_conv.inner = (void*)(data & (~1));
11509         data_conv.is_owned = false;
11510         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11511         LDKMonitorUpdateId update_id_conv;
11512         update_id_conv.inner = (void*)(update_id & (~1));
11513         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11514         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11515         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11516         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11517         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11518         return (int64_t)ret_conv;
11519 }
11520
11521 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) {
11522         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11523         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11524         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11525         LDKOutPoint channel_id_conv;
11526         channel_id_conv.inner = (void*)(channel_id & (~1));
11527         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11528         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11529         channel_id_conv = OutPoint_clone(&channel_id_conv);
11530         LDKChannelMonitorUpdate update_conv;
11531         update_conv.inner = (void*)(update & (~1));
11532         update_conv.is_owned = false;
11533         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11534         LDKChannelMonitor data_conv;
11535         data_conv.inner = (void*)(data & (~1));
11536         data_conv.is_owned = false;
11537         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11538         LDKMonitorUpdateId update_id_conv;
11539         update_id_conv.inner = (void*)(update_id & (~1));
11540         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11541         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11542         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11543         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11544         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11545         return (int64_t)ret_conv;
11546 }
11547
11548 typedef struct LDKChannelMessageHandler_JCalls {
11549         atomic_size_t refcnt;
11550         JavaVM *vm;
11551         jweak o;
11552         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11553         jmethodID handle_open_channel_meth;
11554         jmethodID handle_accept_channel_meth;
11555         jmethodID handle_funding_created_meth;
11556         jmethodID handle_funding_signed_meth;
11557         jmethodID handle_channel_ready_meth;
11558         jmethodID handle_shutdown_meth;
11559         jmethodID handle_closing_signed_meth;
11560         jmethodID handle_update_add_htlc_meth;
11561         jmethodID handle_update_fulfill_htlc_meth;
11562         jmethodID handle_update_fail_htlc_meth;
11563         jmethodID handle_update_fail_malformed_htlc_meth;
11564         jmethodID handle_commitment_signed_meth;
11565         jmethodID handle_revoke_and_ack_meth;
11566         jmethodID handle_update_fee_meth;
11567         jmethodID handle_announcement_signatures_meth;
11568         jmethodID peer_disconnected_meth;
11569         jmethodID peer_connected_meth;
11570         jmethodID handle_channel_reestablish_meth;
11571         jmethodID handle_channel_update_meth;
11572         jmethodID handle_error_meth;
11573 } LDKChannelMessageHandler_JCalls;
11574 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11575         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11576         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11577                 JNIEnv *env;
11578                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11579                 if (get_jenv_res == JNI_EDETACHED) {
11580                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11581                 } else {
11582                         DO_ASSERT(get_jenv_res == JNI_OK);
11583                 }
11584                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11585                 if (get_jenv_res == JNI_EDETACHED) {
11586                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11587                 }
11588                 FREE(j_calls);
11589         }
11590 }
11591 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11592         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11593         JNIEnv *env;
11594         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11595         if (get_jenv_res == JNI_EDETACHED) {
11596                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11597         } else {
11598                 DO_ASSERT(get_jenv_res == JNI_OK);
11599         }
11600         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11601         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11602         LDKInitFeatures their_features_var = their_features;
11603         int64_t their_features_ref = 0;
11604         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11605         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11606         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11607         their_features_ref = (uintptr_t)their_features_var.inner;
11608         if (their_features_var.is_owned) {
11609                 their_features_ref |= 1;
11610         }
11611         LDKOpenChannel msg_var = *msg;
11612         int64_t msg_ref = 0;
11613         msg_var = OpenChannel_clone(&msg_var);
11614         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11615         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11616         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11617         msg_ref = (uintptr_t)msg_var.inner;
11618         if (msg_var.is_owned) {
11619                 msg_ref |= 1;
11620         }
11621         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11622         CHECK(obj != NULL);
11623         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11624         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11625                 (*env)->ExceptionDescribe(env);
11626                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11627         }
11628         if (get_jenv_res == JNI_EDETACHED) {
11629                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11630         }
11631 }
11632 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11633         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11634         JNIEnv *env;
11635         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11636         if (get_jenv_res == JNI_EDETACHED) {
11637                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11638         } else {
11639                 DO_ASSERT(get_jenv_res == JNI_OK);
11640         }
11641         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11642         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11643         LDKInitFeatures their_features_var = their_features;
11644         int64_t their_features_ref = 0;
11645         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11646         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11647         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11648         their_features_ref = (uintptr_t)their_features_var.inner;
11649         if (their_features_var.is_owned) {
11650                 their_features_ref |= 1;
11651         }
11652         LDKAcceptChannel msg_var = *msg;
11653         int64_t msg_ref = 0;
11654         msg_var = AcceptChannel_clone(&msg_var);
11655         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11656         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11657         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11658         msg_ref = (uintptr_t)msg_var.inner;
11659         if (msg_var.is_owned) {
11660                 msg_ref |= 1;
11661         }
11662         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11663         CHECK(obj != NULL);
11664         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11665         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11666                 (*env)->ExceptionDescribe(env);
11667                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
11668         }
11669         if (get_jenv_res == JNI_EDETACHED) {
11670                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11671         }
11672 }
11673 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
11674         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11675         JNIEnv *env;
11676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11677         if (get_jenv_res == JNI_EDETACHED) {
11678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11679         } else {
11680                 DO_ASSERT(get_jenv_res == JNI_OK);
11681         }
11682         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11683         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11684         LDKFundingCreated msg_var = *msg;
11685         int64_t msg_ref = 0;
11686         msg_var = FundingCreated_clone(&msg_var);
11687         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11688         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11689         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11690         msg_ref = (uintptr_t)msg_var.inner;
11691         if (msg_var.is_owned) {
11692                 msg_ref |= 1;
11693         }
11694         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11695         CHECK(obj != NULL);
11696         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
11697         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11698                 (*env)->ExceptionDescribe(env);
11699                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
11700         }
11701         if (get_jenv_res == JNI_EDETACHED) {
11702                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11703         }
11704 }
11705 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
11706         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11707         JNIEnv *env;
11708         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11709         if (get_jenv_res == JNI_EDETACHED) {
11710                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11711         } else {
11712                 DO_ASSERT(get_jenv_res == JNI_OK);
11713         }
11714         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11715         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11716         LDKFundingSigned msg_var = *msg;
11717         int64_t msg_ref = 0;
11718         msg_var = FundingSigned_clone(&msg_var);
11719         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11720         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11721         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11722         msg_ref = (uintptr_t)msg_var.inner;
11723         if (msg_var.is_owned) {
11724                 msg_ref |= 1;
11725         }
11726         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11727         CHECK(obj != NULL);
11728         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
11729         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11730                 (*env)->ExceptionDescribe(env);
11731                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
11732         }
11733         if (get_jenv_res == JNI_EDETACHED) {
11734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11735         }
11736 }
11737 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
11738         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11739         JNIEnv *env;
11740         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11741         if (get_jenv_res == JNI_EDETACHED) {
11742                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11743         } else {
11744                 DO_ASSERT(get_jenv_res == JNI_OK);
11745         }
11746         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11747         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11748         LDKChannelReady msg_var = *msg;
11749         int64_t msg_ref = 0;
11750         msg_var = ChannelReady_clone(&msg_var);
11751         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11752         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11753         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11754         msg_ref = (uintptr_t)msg_var.inner;
11755         if (msg_var.is_owned) {
11756                 msg_ref |= 1;
11757         }
11758         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11759         CHECK(obj != NULL);
11760         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
11761         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11762                 (*env)->ExceptionDescribe(env);
11763                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
11764         }
11765         if (get_jenv_res == JNI_EDETACHED) {
11766                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11767         }
11768 }
11769 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
11770         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11771         JNIEnv *env;
11772         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11773         if (get_jenv_res == JNI_EDETACHED) {
11774                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11775         } else {
11776                 DO_ASSERT(get_jenv_res == JNI_OK);
11777         }
11778         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11779         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11780         LDKInitFeatures their_features_var = *their_features;
11781         int64_t their_features_ref = 0;
11782         their_features_var = InitFeatures_clone(&their_features_var);
11783         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11784         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11785         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11786         their_features_ref = (uintptr_t)their_features_var.inner;
11787         if (their_features_var.is_owned) {
11788                 their_features_ref |= 1;
11789         }
11790         LDKShutdown msg_var = *msg;
11791         int64_t msg_ref = 0;
11792         msg_var = Shutdown_clone(&msg_var);
11793         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11794         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11796         msg_ref = (uintptr_t)msg_var.inner;
11797         if (msg_var.is_owned) {
11798                 msg_ref |= 1;
11799         }
11800         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11801         CHECK(obj != NULL);
11802         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11803         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11804                 (*env)->ExceptionDescribe(env);
11805                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11806         }
11807         if (get_jenv_res == JNI_EDETACHED) {
11808                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11809         }
11810 }
11811 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11813         JNIEnv *env;
11814         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11815         if (get_jenv_res == JNI_EDETACHED) {
11816                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11817         } else {
11818                 DO_ASSERT(get_jenv_res == JNI_OK);
11819         }
11820         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11821         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11822         LDKClosingSigned msg_var = *msg;
11823         int64_t msg_ref = 0;
11824         msg_var = ClosingSigned_clone(&msg_var);
11825         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11826         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11827         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11828         msg_ref = (uintptr_t)msg_var.inner;
11829         if (msg_var.is_owned) {
11830                 msg_ref |= 1;
11831         }
11832         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11833         CHECK(obj != NULL);
11834         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11835         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11836                 (*env)->ExceptionDescribe(env);
11837                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11838         }
11839         if (get_jenv_res == JNI_EDETACHED) {
11840                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11841         }
11842 }
11843 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11844         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11845         JNIEnv *env;
11846         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11847         if (get_jenv_res == JNI_EDETACHED) {
11848                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11849         } else {
11850                 DO_ASSERT(get_jenv_res == JNI_OK);
11851         }
11852         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11853         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11854         LDKUpdateAddHTLC msg_var = *msg;
11855         int64_t msg_ref = 0;
11856         msg_var = UpdateAddHTLC_clone(&msg_var);
11857         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11858         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11859         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11860         msg_ref = (uintptr_t)msg_var.inner;
11861         if (msg_var.is_owned) {
11862                 msg_ref |= 1;
11863         }
11864         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11865         CHECK(obj != NULL);
11866         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11867         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11868                 (*env)->ExceptionDescribe(env);
11869                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11870         }
11871         if (get_jenv_res == JNI_EDETACHED) {
11872                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11873         }
11874 }
11875 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11876         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11877         JNIEnv *env;
11878         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11879         if (get_jenv_res == JNI_EDETACHED) {
11880                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11881         } else {
11882                 DO_ASSERT(get_jenv_res == JNI_OK);
11883         }
11884         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11885         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11886         LDKUpdateFulfillHTLC msg_var = *msg;
11887         int64_t msg_ref = 0;
11888         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11889         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11890         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11892         msg_ref = (uintptr_t)msg_var.inner;
11893         if (msg_var.is_owned) {
11894                 msg_ref |= 1;
11895         }
11896         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11897         CHECK(obj != NULL);
11898         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11899         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11900                 (*env)->ExceptionDescribe(env);
11901                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11902         }
11903         if (get_jenv_res == JNI_EDETACHED) {
11904                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11905         }
11906 }
11907 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11908         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11909         JNIEnv *env;
11910         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11911         if (get_jenv_res == JNI_EDETACHED) {
11912                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11913         } else {
11914                 DO_ASSERT(get_jenv_res == JNI_OK);
11915         }
11916         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11917         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11918         LDKUpdateFailHTLC msg_var = *msg;
11919         int64_t msg_ref = 0;
11920         msg_var = UpdateFailHTLC_clone(&msg_var);
11921         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11922         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11924         msg_ref = (uintptr_t)msg_var.inner;
11925         if (msg_var.is_owned) {
11926                 msg_ref |= 1;
11927         }
11928         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11929         CHECK(obj != NULL);
11930         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11931         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11932                 (*env)->ExceptionDescribe(env);
11933                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11934         }
11935         if (get_jenv_res == JNI_EDETACHED) {
11936                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11937         }
11938 }
11939 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11940         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11941         JNIEnv *env;
11942         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11943         if (get_jenv_res == JNI_EDETACHED) {
11944                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11945         } else {
11946                 DO_ASSERT(get_jenv_res == JNI_OK);
11947         }
11948         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11949         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11950         LDKUpdateFailMalformedHTLC msg_var = *msg;
11951         int64_t msg_ref = 0;
11952         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11953         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11954         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11956         msg_ref = (uintptr_t)msg_var.inner;
11957         if (msg_var.is_owned) {
11958                 msg_ref |= 1;
11959         }
11960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11961         CHECK(obj != NULL);
11962         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11963         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11964                 (*env)->ExceptionDescribe(env);
11965                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11966         }
11967         if (get_jenv_res == JNI_EDETACHED) {
11968                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11969         }
11970 }
11971 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11972         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11973         JNIEnv *env;
11974         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11975         if (get_jenv_res == JNI_EDETACHED) {
11976                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11977         } else {
11978                 DO_ASSERT(get_jenv_res == JNI_OK);
11979         }
11980         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11981         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11982         LDKCommitmentSigned msg_var = *msg;
11983         int64_t msg_ref = 0;
11984         msg_var = CommitmentSigned_clone(&msg_var);
11985         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11986         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11987         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11988         msg_ref = (uintptr_t)msg_var.inner;
11989         if (msg_var.is_owned) {
11990                 msg_ref |= 1;
11991         }
11992         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11993         CHECK(obj != NULL);
11994         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11995         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11996                 (*env)->ExceptionDescribe(env);
11997                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11998         }
11999         if (get_jenv_res == JNI_EDETACHED) {
12000                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12001         }
12002 }
12003 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12004         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12005         JNIEnv *env;
12006         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12007         if (get_jenv_res == JNI_EDETACHED) {
12008                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12009         } else {
12010                 DO_ASSERT(get_jenv_res == JNI_OK);
12011         }
12012         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12013         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12014         LDKRevokeAndACK msg_var = *msg;
12015         int64_t msg_ref = 0;
12016         msg_var = RevokeAndACK_clone(&msg_var);
12017         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12018         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12020         msg_ref = (uintptr_t)msg_var.inner;
12021         if (msg_var.is_owned) {
12022                 msg_ref |= 1;
12023         }
12024         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12025         CHECK(obj != NULL);
12026         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12027         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12028                 (*env)->ExceptionDescribe(env);
12029                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12030         }
12031         if (get_jenv_res == JNI_EDETACHED) {
12032                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12033         }
12034 }
12035 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12036         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12037         JNIEnv *env;
12038         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12039         if (get_jenv_res == JNI_EDETACHED) {
12040                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12041         } else {
12042                 DO_ASSERT(get_jenv_res == JNI_OK);
12043         }
12044         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12045         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12046         LDKUpdateFee msg_var = *msg;
12047         int64_t msg_ref = 0;
12048         msg_var = UpdateFee_clone(&msg_var);
12049         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12050         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12052         msg_ref = (uintptr_t)msg_var.inner;
12053         if (msg_var.is_owned) {
12054                 msg_ref |= 1;
12055         }
12056         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12057         CHECK(obj != NULL);
12058         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12059         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12060                 (*env)->ExceptionDescribe(env);
12061                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12062         }
12063         if (get_jenv_res == JNI_EDETACHED) {
12064                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12065         }
12066 }
12067 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12068         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12069         JNIEnv *env;
12070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12071         if (get_jenv_res == JNI_EDETACHED) {
12072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12073         } else {
12074                 DO_ASSERT(get_jenv_res == JNI_OK);
12075         }
12076         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12077         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12078         LDKAnnouncementSignatures msg_var = *msg;
12079         int64_t msg_ref = 0;
12080         msg_var = AnnouncementSignatures_clone(&msg_var);
12081         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12082         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12084         msg_ref = (uintptr_t)msg_var.inner;
12085         if (msg_var.is_owned) {
12086                 msg_ref |= 1;
12087         }
12088         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12089         CHECK(obj != NULL);
12090         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12091         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12092                 (*env)->ExceptionDescribe(env);
12093                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12094         }
12095         if (get_jenv_res == JNI_EDETACHED) {
12096                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12097         }
12098 }
12099 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12100         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12101         JNIEnv *env;
12102         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12103         if (get_jenv_res == JNI_EDETACHED) {
12104                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12105         } else {
12106                 DO_ASSERT(get_jenv_res == JNI_OK);
12107         }
12108         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12109         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12110         jboolean no_connection_possible_conv = no_connection_possible;
12111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12112         CHECK(obj != NULL);
12113         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12114         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12115                 (*env)->ExceptionDescribe(env);
12116                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12117         }
12118         if (get_jenv_res == JNI_EDETACHED) {
12119                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12120         }
12121 }
12122 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12123         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12124         JNIEnv *env;
12125         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12126         if (get_jenv_res == JNI_EDETACHED) {
12127                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12128         } else {
12129                 DO_ASSERT(get_jenv_res == JNI_OK);
12130         }
12131         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12132         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12133         LDKInit msg_var = *msg;
12134         int64_t msg_ref = 0;
12135         msg_var = Init_clone(&msg_var);
12136         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12137         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12138         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12139         msg_ref = (uintptr_t)msg_var.inner;
12140         if (msg_var.is_owned) {
12141                 msg_ref |= 1;
12142         }
12143         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12144         CHECK(obj != NULL);
12145         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12146         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12147                 (*env)->ExceptionDescribe(env);
12148                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12149         }
12150         if (get_jenv_res == JNI_EDETACHED) {
12151                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12152         }
12153 }
12154 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12155         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12156         JNIEnv *env;
12157         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12158         if (get_jenv_res == JNI_EDETACHED) {
12159                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12160         } else {
12161                 DO_ASSERT(get_jenv_res == JNI_OK);
12162         }
12163         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12164         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12165         LDKChannelReestablish msg_var = *msg;
12166         int64_t msg_ref = 0;
12167         msg_var = ChannelReestablish_clone(&msg_var);
12168         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12169         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12170         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12171         msg_ref = (uintptr_t)msg_var.inner;
12172         if (msg_var.is_owned) {
12173                 msg_ref |= 1;
12174         }
12175         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12176         CHECK(obj != NULL);
12177         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12178         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12179                 (*env)->ExceptionDescribe(env);
12180                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12181         }
12182         if (get_jenv_res == JNI_EDETACHED) {
12183                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12184         }
12185 }
12186 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12187         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12188         JNIEnv *env;
12189         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12190         if (get_jenv_res == JNI_EDETACHED) {
12191                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12192         } else {
12193                 DO_ASSERT(get_jenv_res == JNI_OK);
12194         }
12195         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12196         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12197         LDKChannelUpdate msg_var = *msg;
12198         int64_t msg_ref = 0;
12199         msg_var = ChannelUpdate_clone(&msg_var);
12200         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12201         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12202         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12203         msg_ref = (uintptr_t)msg_var.inner;
12204         if (msg_var.is_owned) {
12205                 msg_ref |= 1;
12206         }
12207         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12208         CHECK(obj != NULL);
12209         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12210         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12211                 (*env)->ExceptionDescribe(env);
12212                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12213         }
12214         if (get_jenv_res == JNI_EDETACHED) {
12215                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12216         }
12217 }
12218 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12219         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12220         JNIEnv *env;
12221         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12222         if (get_jenv_res == JNI_EDETACHED) {
12223                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12224         } else {
12225                 DO_ASSERT(get_jenv_res == JNI_OK);
12226         }
12227         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12228         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12229         LDKErrorMessage msg_var = *msg;
12230         int64_t msg_ref = 0;
12231         msg_var = ErrorMessage_clone(&msg_var);
12232         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12233         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12234         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12235         msg_ref = (uintptr_t)msg_var.inner;
12236         if (msg_var.is_owned) {
12237                 msg_ref |= 1;
12238         }
12239         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12240         CHECK(obj != NULL);
12241         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12242         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12243                 (*env)->ExceptionDescribe(env);
12244                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12245         }
12246         if (get_jenv_res == JNI_EDETACHED) {
12247                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12248         }
12249 }
12250 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12251         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12252         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12253         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12254 }
12255 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12256         jclass c = (*env)->GetObjectClass(env, o);
12257         CHECK(c != NULL);
12258         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12259         atomic_init(&calls->refcnt, 1);
12260         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12261         calls->o = (*env)->NewWeakGlobalRef(env, o);
12262         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12263         CHECK(calls->handle_open_channel_meth != NULL);
12264         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12265         CHECK(calls->handle_accept_channel_meth != NULL);
12266         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12267         CHECK(calls->handle_funding_created_meth != NULL);
12268         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12269         CHECK(calls->handle_funding_signed_meth != NULL);
12270         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12271         CHECK(calls->handle_channel_ready_meth != NULL);
12272         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12273         CHECK(calls->handle_shutdown_meth != NULL);
12274         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12275         CHECK(calls->handle_closing_signed_meth != NULL);
12276         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12277         CHECK(calls->handle_update_add_htlc_meth != NULL);
12278         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12279         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12280         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12281         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12282         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12283         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12284         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12285         CHECK(calls->handle_commitment_signed_meth != NULL);
12286         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12287         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12288         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12289         CHECK(calls->handle_update_fee_meth != NULL);
12290         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12291         CHECK(calls->handle_announcement_signatures_meth != NULL);
12292         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12293         CHECK(calls->peer_disconnected_meth != NULL);
12294         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12295         CHECK(calls->peer_connected_meth != NULL);
12296         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12297         CHECK(calls->handle_channel_reestablish_meth != NULL);
12298         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12299         CHECK(calls->handle_channel_update_meth != NULL);
12300         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12301         CHECK(calls->handle_error_meth != NULL);
12302
12303         LDKChannelMessageHandler ret = {
12304                 .this_arg = (void*) calls,
12305                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12306                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12307                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12308                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12309                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12310                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12311                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12312                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12313                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12314                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12315                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12316                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12317                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12318                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12319                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12320                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12321                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12322                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12323                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12324                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12325                 .free = LDKChannelMessageHandler_JCalls_free,
12326                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12327         };
12328         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12329         return ret;
12330 }
12331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12332         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12333         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12334         return (uint64_t)res_ptr;
12335 }
12336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12337         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
12338         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12339         DO_ASSERT((res_ptr & 1) == 0);
12340         return (int64_t)(res_ptr | 1);
12341 }
12342 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) {
12343         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12344         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12345         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12346         LDKPublicKey their_node_id_ref;
12347         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12348         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12349         LDKInitFeatures their_features_conv;
12350         their_features_conv.inner = (void*)(their_features & (~1));
12351         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12352         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12353         their_features_conv = InitFeatures_clone(&their_features_conv);
12354         LDKOpenChannel msg_conv;
12355         msg_conv.inner = (void*)(msg & (~1));
12356         msg_conv.is_owned = false;
12357         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12358         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12359 }
12360
12361 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) {
12362         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12364         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12365         LDKPublicKey their_node_id_ref;
12366         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12367         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12368         LDKInitFeatures their_features_conv;
12369         their_features_conv.inner = (void*)(their_features & (~1));
12370         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12371         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12372         their_features_conv = InitFeatures_clone(&their_features_conv);
12373         LDKAcceptChannel msg_conv;
12374         msg_conv.inner = (void*)(msg & (~1));
12375         msg_conv.is_owned = false;
12376         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12377         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12378 }
12379
12380 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) {
12381         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12382         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12383         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12384         LDKPublicKey their_node_id_ref;
12385         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12386         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12387         LDKFundingCreated msg_conv;
12388         msg_conv.inner = (void*)(msg & (~1));
12389         msg_conv.is_owned = false;
12390         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12391         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12392 }
12393
12394 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) {
12395         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12396         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12397         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12398         LDKPublicKey their_node_id_ref;
12399         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12400         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12401         LDKFundingSigned msg_conv;
12402         msg_conv.inner = (void*)(msg & (~1));
12403         msg_conv.is_owned = false;
12404         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12405         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12406 }
12407
12408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12409         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12410         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12411         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12412         LDKPublicKey their_node_id_ref;
12413         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12414         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12415         LDKChannelReady msg_conv;
12416         msg_conv.inner = (void*)(msg & (~1));
12417         msg_conv.is_owned = false;
12418         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12419         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12420 }
12421
12422 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) {
12423         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12424         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12425         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12426         LDKPublicKey their_node_id_ref;
12427         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12428         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12429         LDKInitFeatures their_features_conv;
12430         their_features_conv.inner = (void*)(their_features & (~1));
12431         their_features_conv.is_owned = false;
12432         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12433         LDKShutdown msg_conv;
12434         msg_conv.inner = (void*)(msg & (~1));
12435         msg_conv.is_owned = false;
12436         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12437         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12438 }
12439
12440 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) {
12441         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12442         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12443         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12444         LDKPublicKey their_node_id_ref;
12445         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12446         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12447         LDKClosingSigned msg_conv;
12448         msg_conv.inner = (void*)(msg & (~1));
12449         msg_conv.is_owned = false;
12450         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12451         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12452 }
12453
12454 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) {
12455         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12456         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12457         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12458         LDKPublicKey their_node_id_ref;
12459         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12460         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12461         LDKUpdateAddHTLC msg_conv;
12462         msg_conv.inner = (void*)(msg & (~1));
12463         msg_conv.is_owned = false;
12464         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12465         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12466 }
12467
12468 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) {
12469         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12470         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12471         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12472         LDKPublicKey their_node_id_ref;
12473         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12474         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12475         LDKUpdateFulfillHTLC msg_conv;
12476         msg_conv.inner = (void*)(msg & (~1));
12477         msg_conv.is_owned = false;
12478         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12479         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12480 }
12481
12482 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) {
12483         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12484         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12485         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12486         LDKPublicKey their_node_id_ref;
12487         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12488         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12489         LDKUpdateFailHTLC msg_conv;
12490         msg_conv.inner = (void*)(msg & (~1));
12491         msg_conv.is_owned = false;
12492         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12493         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12494 }
12495
12496 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) {
12497         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12498         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12499         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12500         LDKPublicKey their_node_id_ref;
12501         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12502         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12503         LDKUpdateFailMalformedHTLC msg_conv;
12504         msg_conv.inner = (void*)(msg & (~1));
12505         msg_conv.is_owned = false;
12506         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12507         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12508 }
12509
12510 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) {
12511         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12512         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12513         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12514         LDKPublicKey their_node_id_ref;
12515         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12516         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12517         LDKCommitmentSigned msg_conv;
12518         msg_conv.inner = (void*)(msg & (~1));
12519         msg_conv.is_owned = false;
12520         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12521         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12522 }
12523
12524 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) {
12525         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12526         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12527         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12528         LDKPublicKey their_node_id_ref;
12529         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12530         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12531         LDKRevokeAndACK msg_conv;
12532         msg_conv.inner = (void*)(msg & (~1));
12533         msg_conv.is_owned = false;
12534         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12535         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12536 }
12537
12538 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) {
12539         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12540         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12541         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12542         LDKPublicKey their_node_id_ref;
12543         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12544         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12545         LDKUpdateFee msg_conv;
12546         msg_conv.inner = (void*)(msg & (~1));
12547         msg_conv.is_owned = false;
12548         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12549         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12550 }
12551
12552 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) {
12553         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12554         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12555         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12556         LDKPublicKey their_node_id_ref;
12557         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12558         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12559         LDKAnnouncementSignatures msg_conv;
12560         msg_conv.inner = (void*)(msg & (~1));
12561         msg_conv.is_owned = false;
12562         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12563         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12564 }
12565
12566 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) {
12567         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12568         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12569         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12570         LDKPublicKey their_node_id_ref;
12571         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12572         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12573         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12574 }
12575
12576 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) {
12577         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12578         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12579         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12580         LDKPublicKey their_node_id_ref;
12581         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12582         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12583         LDKInit msg_conv;
12584         msg_conv.inner = (void*)(msg & (~1));
12585         msg_conv.is_owned = false;
12586         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12587         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12588 }
12589
12590 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) {
12591         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12592         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12593         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12594         LDKPublicKey their_node_id_ref;
12595         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12596         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12597         LDKChannelReestablish msg_conv;
12598         msg_conv.inner = (void*)(msg & (~1));
12599         msg_conv.is_owned = false;
12600         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12601         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12602 }
12603
12604 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) {
12605         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12606         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12607         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12608         LDKPublicKey their_node_id_ref;
12609         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12610         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12611         LDKChannelUpdate msg_conv;
12612         msg_conv.inner = (void*)(msg & (~1));
12613         msg_conv.is_owned = false;
12614         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12615         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12616 }
12617
12618 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) {
12619         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12620         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12621         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12622         LDKPublicKey their_node_id_ref;
12623         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12624         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12625         LDKErrorMessage msg_conv;
12626         msg_conv.inner = (void*)(msg & (~1));
12627         msg_conv.is_owned = false;
12628         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12629         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12630 }
12631
12632 typedef struct LDKRoutingMessageHandler_JCalls {
12633         atomic_size_t refcnt;
12634         JavaVM *vm;
12635         jweak o;
12636         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12637         jmethodID handle_node_announcement_meth;
12638         jmethodID handle_channel_announcement_meth;
12639         jmethodID handle_channel_update_meth;
12640         jmethodID get_next_channel_announcements_meth;
12641         jmethodID get_next_node_announcements_meth;
12642         jmethodID peer_connected_meth;
12643         jmethodID handle_reply_channel_range_meth;
12644         jmethodID handle_reply_short_channel_ids_end_meth;
12645         jmethodID handle_query_channel_range_meth;
12646         jmethodID handle_query_short_channel_ids_meth;
12647 } LDKRoutingMessageHandler_JCalls;
12648 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12649         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12650         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12651                 JNIEnv *env;
12652                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12653                 if (get_jenv_res == JNI_EDETACHED) {
12654                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12655                 } else {
12656                         DO_ASSERT(get_jenv_res == JNI_OK);
12657                 }
12658                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12659                 if (get_jenv_res == JNI_EDETACHED) {
12660                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12661                 }
12662                 FREE(j_calls);
12663         }
12664 }
12665 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12666         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12667         JNIEnv *env;
12668         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12669         if (get_jenv_res == JNI_EDETACHED) {
12670                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12671         } else {
12672                 DO_ASSERT(get_jenv_res == JNI_OK);
12673         }
12674         LDKNodeAnnouncement msg_var = *msg;
12675         int64_t msg_ref = 0;
12676         msg_var = NodeAnnouncement_clone(&msg_var);
12677         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12678         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12679         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12680         msg_ref = (uintptr_t)msg_var.inner;
12681         if (msg_var.is_owned) {
12682                 msg_ref |= 1;
12683         }
12684         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12685         CHECK(obj != NULL);
12686         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
12687         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12688                 (*env)->ExceptionDescribe(env);
12689                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12690         }
12691         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12692         CHECK_ACCESS(ret_ptr);
12693         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12694         FREE((void*)ret);
12695         if (get_jenv_res == JNI_EDETACHED) {
12696                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12697         }
12698         return ret_conv;
12699 }
12700 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
12701         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12702         JNIEnv *env;
12703         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12704         if (get_jenv_res == JNI_EDETACHED) {
12705                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12706         } else {
12707                 DO_ASSERT(get_jenv_res == JNI_OK);
12708         }
12709         LDKChannelAnnouncement msg_var = *msg;
12710         int64_t msg_ref = 0;
12711         msg_var = ChannelAnnouncement_clone(&msg_var);
12712         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12713         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12714         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12715         msg_ref = (uintptr_t)msg_var.inner;
12716         if (msg_var.is_owned) {
12717                 msg_ref |= 1;
12718         }
12719         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12720         CHECK(obj != NULL);
12721         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
12722         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12723                 (*env)->ExceptionDescribe(env);
12724                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12725         }
12726         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12727         CHECK_ACCESS(ret_ptr);
12728         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12729         FREE((void*)ret);
12730         if (get_jenv_res == JNI_EDETACHED) {
12731                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12732         }
12733         return ret_conv;
12734 }
12735 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
12736         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12737         JNIEnv *env;
12738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12739         if (get_jenv_res == JNI_EDETACHED) {
12740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12741         } else {
12742                 DO_ASSERT(get_jenv_res == JNI_OK);
12743         }
12744         LDKChannelUpdate msg_var = *msg;
12745         int64_t msg_ref = 0;
12746         msg_var = ChannelUpdate_clone(&msg_var);
12747         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12748         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12750         msg_ref = (uintptr_t)msg_var.inner;
12751         if (msg_var.is_owned) {
12752                 msg_ref |= 1;
12753         }
12754         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12755         CHECK(obj != NULL);
12756         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
12757         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12758                 (*env)->ExceptionDescribe(env);
12759                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
12760         }
12761         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12762         CHECK_ACCESS(ret_ptr);
12763         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12764         FREE((void*)ret);
12765         if (get_jenv_res == JNI_EDETACHED) {
12766                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12767         }
12768         return ret_conv;
12769 }
12770 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
12771         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12772         JNIEnv *env;
12773         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12774         if (get_jenv_res == JNI_EDETACHED) {
12775                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12776         } else {
12777                 DO_ASSERT(get_jenv_res == JNI_OK);
12778         }
12779         int64_t starting_point_conv = starting_point;
12780         int8_t batch_amount_conv = batch_amount;
12781         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12782         CHECK(obj != NULL);
12783         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
12784         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12785                 (*env)->ExceptionDescribe(env);
12786                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12787         }
12788         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
12789         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12790         if (ret_constr.datalen > 0)
12791                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
12792         else
12793                 ret_constr.data = NULL;
12794         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12795         for (size_t h = 0; h < ret_constr.datalen; h++) {
12796                 int64_t ret_conv_59 = ret_vals[h];
12797                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
12798                 CHECK_ACCESS(ret_conv_59_ptr);
12799                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
12800                 FREE((void*)ret_conv_59);
12801                 ret_constr.data[h] = ret_conv_59_conv;
12802         }
12803         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12804         if (get_jenv_res == JNI_EDETACHED) {
12805                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12806         }
12807         return ret_constr;
12808 }
12809 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
12810         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12811         JNIEnv *env;
12812         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12813         if (get_jenv_res == JNI_EDETACHED) {
12814                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12815         } else {
12816                 DO_ASSERT(get_jenv_res == JNI_OK);
12817         }
12818         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12819         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12820         int8_t batch_amount_conv = batch_amount;
12821         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12822         CHECK(obj != NULL);
12823         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
12824         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12825                 (*env)->ExceptionDescribe(env);
12826                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12827         }
12828         LDKCVec_NodeAnnouncementZ ret_constr;
12829         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12830         if (ret_constr.datalen > 0)
12831                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
12832         else
12833                 ret_constr.data = NULL;
12834         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12835         for (size_t s = 0; s < ret_constr.datalen; s++) {
12836                 int64_t ret_conv_18 = ret_vals[s];
12837                 LDKNodeAnnouncement ret_conv_18_conv;
12838                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
12839                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
12840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
12841                 ret_constr.data[s] = ret_conv_18_conv;
12842         }
12843         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12844         if (get_jenv_res == JNI_EDETACHED) {
12845                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12846         }
12847         return ret_constr;
12848 }
12849 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12850         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12851         JNIEnv *env;
12852         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12853         if (get_jenv_res == JNI_EDETACHED) {
12854                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12855         } else {
12856                 DO_ASSERT(get_jenv_res == JNI_OK);
12857         }
12858         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12859         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12860         LDKInit init_var = *init;
12861         int64_t init_ref = 0;
12862         init_var = Init_clone(&init_var);
12863         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12864         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12865         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12866         init_ref = (uintptr_t)init_var.inner;
12867         if (init_var.is_owned) {
12868                 init_ref |= 1;
12869         }
12870         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12871         CHECK(obj != NULL);
12872         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12873         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12874                 (*env)->ExceptionDescribe(env);
12875                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
12876         }
12877         if (get_jenv_res == JNI_EDETACHED) {
12878                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12879         }
12880 }
12881 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12882         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12883         JNIEnv *env;
12884         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12885         if (get_jenv_res == JNI_EDETACHED) {
12886                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12887         } else {
12888                 DO_ASSERT(get_jenv_res == JNI_OK);
12889         }
12890         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12891         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12892         LDKReplyChannelRange msg_var = msg;
12893         int64_t msg_ref = 0;
12894         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12895         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12896         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12897         msg_ref = (uintptr_t)msg_var.inner;
12898         if (msg_var.is_owned) {
12899                 msg_ref |= 1;
12900         }
12901         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12902         CHECK(obj != NULL);
12903         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12904         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12905                 (*env)->ExceptionDescribe(env);
12906                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12907         }
12908         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12909         CHECK_ACCESS(ret_ptr);
12910         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12911         FREE((void*)ret);
12912         if (get_jenv_res == JNI_EDETACHED) {
12913                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12914         }
12915         return ret_conv;
12916 }
12917 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12918         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12919         JNIEnv *env;
12920         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12921         if (get_jenv_res == JNI_EDETACHED) {
12922                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12923         } else {
12924                 DO_ASSERT(get_jenv_res == JNI_OK);
12925         }
12926         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12927         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12928         LDKReplyShortChannelIdsEnd msg_var = msg;
12929         int64_t msg_ref = 0;
12930         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12931         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12932         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12933         msg_ref = (uintptr_t)msg_var.inner;
12934         if (msg_var.is_owned) {
12935                 msg_ref |= 1;
12936         }
12937         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12938         CHECK(obj != NULL);
12939         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12940         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12941                 (*env)->ExceptionDescribe(env);
12942                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12943         }
12944         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12945         CHECK_ACCESS(ret_ptr);
12946         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12947         FREE((void*)ret);
12948         if (get_jenv_res == JNI_EDETACHED) {
12949                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12950         }
12951         return ret_conv;
12952 }
12953 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12954         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12955         JNIEnv *env;
12956         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12957         if (get_jenv_res == JNI_EDETACHED) {
12958                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12959         } else {
12960                 DO_ASSERT(get_jenv_res == JNI_OK);
12961         }
12962         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12963         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12964         LDKQueryChannelRange msg_var = msg;
12965         int64_t msg_ref = 0;
12966         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12967         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12968         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12969         msg_ref = (uintptr_t)msg_var.inner;
12970         if (msg_var.is_owned) {
12971                 msg_ref |= 1;
12972         }
12973         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12974         CHECK(obj != NULL);
12975         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12976         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12977                 (*env)->ExceptionDescribe(env);
12978                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12979         }
12980         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12981         CHECK_ACCESS(ret_ptr);
12982         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12983         FREE((void*)ret);
12984         if (get_jenv_res == JNI_EDETACHED) {
12985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12986         }
12987         return ret_conv;
12988 }
12989 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12990         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12991         JNIEnv *env;
12992         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12993         if (get_jenv_res == JNI_EDETACHED) {
12994                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12995         } else {
12996                 DO_ASSERT(get_jenv_res == JNI_OK);
12997         }
12998         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12999         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13000         LDKQueryShortChannelIds msg_var = msg;
13001         int64_t msg_ref = 0;
13002         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13003         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13005         msg_ref = (uintptr_t)msg_var.inner;
13006         if (msg_var.is_owned) {
13007                 msg_ref |= 1;
13008         }
13009         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13010         CHECK(obj != NULL);
13011         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13012         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13013                 (*env)->ExceptionDescribe(env);
13014                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13015         }
13016         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13017         CHECK_ACCESS(ret_ptr);
13018         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13019         FREE((void*)ret);
13020         if (get_jenv_res == JNI_EDETACHED) {
13021                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13022         }
13023         return ret_conv;
13024 }
13025 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13026         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13027         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13028         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13029 }
13030 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13031         jclass c = (*env)->GetObjectClass(env, o);
13032         CHECK(c != NULL);
13033         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13034         atomic_init(&calls->refcnt, 1);
13035         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13036         calls->o = (*env)->NewWeakGlobalRef(env, o);
13037         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13038         CHECK(calls->handle_node_announcement_meth != NULL);
13039         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13040         CHECK(calls->handle_channel_announcement_meth != NULL);
13041         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13042         CHECK(calls->handle_channel_update_meth != NULL);
13043         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
13044         CHECK(calls->get_next_channel_announcements_meth != NULL);
13045         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
13046         CHECK(calls->get_next_node_announcements_meth != NULL);
13047         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13048         CHECK(calls->peer_connected_meth != NULL);
13049         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13050         CHECK(calls->handle_reply_channel_range_meth != NULL);
13051         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13052         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13053         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13054         CHECK(calls->handle_query_channel_range_meth != NULL);
13055         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13056         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13057
13058         LDKRoutingMessageHandler ret = {
13059                 .this_arg = (void*) calls,
13060                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13061                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13062                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13063                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
13064                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
13065                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13066                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13067                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13068                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13069                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13070                 .free = LDKRoutingMessageHandler_JCalls_free,
13071                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13072         };
13073         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13074         return ret;
13075 }
13076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13077         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13078         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13079         return (uint64_t)res_ptr;
13080 }
13081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13082         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
13083         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
13084         DO_ASSERT((res_ptr & 1) == 0);
13085         return (int64_t)(res_ptr | 1);
13086 }
13087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13088         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13089         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13090         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13091         LDKNodeAnnouncement msg_conv;
13092         msg_conv.inner = (void*)(msg & (~1));
13093         msg_conv.is_owned = false;
13094         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13095         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13096         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13097         return (int64_t)ret_conv;
13098 }
13099
13100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13101         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13102         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13103         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13104         LDKChannelAnnouncement msg_conv;
13105         msg_conv.inner = (void*)(msg & (~1));
13106         msg_conv.is_owned = false;
13107         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13108         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13109         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13110         return (int64_t)ret_conv;
13111 }
13112
13113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13114         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13115         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13116         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13117         LDKChannelUpdate msg_conv;
13118         msg_conv.inner = (void*)(msg & (~1));
13119         msg_conv.is_owned = false;
13120         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13121         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13122         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13123         return (int64_t)ret_conv;
13124 }
13125
13126 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) {
13127         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13128         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13129         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13130         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
13131         int64_tArray ret_arr = NULL;
13132         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13133         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13134         for (size_t h = 0; h < ret_var.datalen; h++) {
13135                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13136                 *ret_conv_59_conv = ret_var.data[h];
13137                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
13138         }
13139         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13140         FREE(ret_var.data);
13141         return ret_arr;
13142 }
13143
13144 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) {
13145         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13146         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13147         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13148         LDKPublicKey starting_point_ref;
13149         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13150         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13151         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
13152         int64_tArray ret_arr = NULL;
13153         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13154         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13155         for (size_t s = 0; s < ret_var.datalen; s++) {
13156                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
13157                 int64_t ret_conv_18_ref = 0;
13158                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13159                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13160                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
13161                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
13162                 if (ret_conv_18_var.is_owned) {
13163                         ret_conv_18_ref |= 1;
13164                 }
13165                 ret_arr_ptr[s] = ret_conv_18_ref;
13166         }
13167         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13168         FREE(ret_var.data);
13169         return ret_arr;
13170 }
13171
13172 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) {
13173         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13174         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13175         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13176         LDKPublicKey their_node_id_ref;
13177         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13178         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13179         LDKInit init_conv;
13180         init_conv.inner = (void*)(init & (~1));
13181         init_conv.is_owned = false;
13182         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13183         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13184 }
13185
13186 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) {
13187         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13188         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13189         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13190         LDKPublicKey their_node_id_ref;
13191         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13192         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13193         LDKReplyChannelRange msg_conv;
13194         msg_conv.inner = (void*)(msg & (~1));
13195         msg_conv.is_owned = (msg & 1) || (msg == 0);
13196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13197         msg_conv = ReplyChannelRange_clone(&msg_conv);
13198         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13199         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13200         return (int64_t)ret_conv;
13201 }
13202
13203 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) {
13204         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13205         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13206         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13207         LDKPublicKey their_node_id_ref;
13208         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13209         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13210         LDKReplyShortChannelIdsEnd msg_conv;
13211         msg_conv.inner = (void*)(msg & (~1));
13212         msg_conv.is_owned = (msg & 1) || (msg == 0);
13213         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13214         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13215         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13216         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13217         return (int64_t)ret_conv;
13218 }
13219
13220 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) {
13221         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13222         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13223         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13224         LDKPublicKey their_node_id_ref;
13225         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13226         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13227         LDKQueryChannelRange msg_conv;
13228         msg_conv.inner = (void*)(msg & (~1));
13229         msg_conv.is_owned = (msg & 1) || (msg == 0);
13230         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13231         msg_conv = QueryChannelRange_clone(&msg_conv);
13232         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13233         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13234         return (int64_t)ret_conv;
13235 }
13236
13237 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) {
13238         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13239         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13240         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13241         LDKPublicKey their_node_id_ref;
13242         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13243         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13244         LDKQueryShortChannelIds msg_conv;
13245         msg_conv.inner = (void*)(msg & (~1));
13246         msg_conv.is_owned = (msg & 1) || (msg == 0);
13247         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13248         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13249         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13250         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13251         return (int64_t)ret_conv;
13252 }
13253
13254 typedef struct LDKCustomMessageReader_JCalls {
13255         atomic_size_t refcnt;
13256         JavaVM *vm;
13257         jweak o;
13258         jmethodID read_meth;
13259 } LDKCustomMessageReader_JCalls;
13260 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13261         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13262         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13263                 JNIEnv *env;
13264                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13265                 if (get_jenv_res == JNI_EDETACHED) {
13266                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13267                 } else {
13268                         DO_ASSERT(get_jenv_res == JNI_OK);
13269                 }
13270                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13271                 if (get_jenv_res == JNI_EDETACHED) {
13272                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13273                 }
13274                 FREE(j_calls);
13275         }
13276 }
13277 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13278         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13279         JNIEnv *env;
13280         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13281         if (get_jenv_res == JNI_EDETACHED) {
13282                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13283         } else {
13284                 DO_ASSERT(get_jenv_res == JNI_OK);
13285         }
13286         int16_t message_type_conv = message_type;
13287         LDKu8slice buffer_var = buffer;
13288         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13289         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13290         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13291         CHECK(obj != NULL);
13292         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13293         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13294                 (*env)->ExceptionDescribe(env);
13295                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13296         }
13297         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13298         CHECK_ACCESS(ret_ptr);
13299         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13300         FREE((void*)ret);
13301         if (get_jenv_res == JNI_EDETACHED) {
13302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13303         }
13304         return ret_conv;
13305 }
13306 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13307         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13308         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13309 }
13310 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13311         jclass c = (*env)->GetObjectClass(env, o);
13312         CHECK(c != NULL);
13313         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13314         atomic_init(&calls->refcnt, 1);
13315         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13316         calls->o = (*env)->NewWeakGlobalRef(env, o);
13317         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13318         CHECK(calls->read_meth != NULL);
13319
13320         LDKCustomMessageReader ret = {
13321                 .this_arg = (void*) calls,
13322                 .read = read_LDKCustomMessageReader_jcall,
13323                 .free = LDKCustomMessageReader_JCalls_free,
13324         };
13325         return ret;
13326 }
13327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13328         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13329         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13330         return (uint64_t)res_ptr;
13331 }
13332 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) {
13333         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13334         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13335         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13336         LDKu8slice buffer_ref;
13337         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13338         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13339         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13340         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13341         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13342         return (int64_t)ret_conv;
13343 }
13344
13345 typedef struct LDKCustomMessageHandler_JCalls {
13346         atomic_size_t refcnt;
13347         JavaVM *vm;
13348         jweak o;
13349         LDKCustomMessageReader_JCalls* CustomMessageReader;
13350         jmethodID handle_custom_message_meth;
13351         jmethodID get_and_clear_pending_msg_meth;
13352 } LDKCustomMessageHandler_JCalls;
13353 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13354         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13355         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13356                 JNIEnv *env;
13357                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13358                 if (get_jenv_res == JNI_EDETACHED) {
13359                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13360                 } else {
13361                         DO_ASSERT(get_jenv_res == JNI_OK);
13362                 }
13363                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13364                 if (get_jenv_res == JNI_EDETACHED) {
13365                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13366                 }
13367                 FREE(j_calls);
13368         }
13369 }
13370 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13371         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13372         JNIEnv *env;
13373         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13374         if (get_jenv_res == JNI_EDETACHED) {
13375                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13376         } else {
13377                 DO_ASSERT(get_jenv_res == JNI_OK);
13378         }
13379         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13380         *msg_ret = msg;
13381         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13382         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13383         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13384         CHECK(obj != NULL);
13385         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
13386         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13387                 (*env)->ExceptionDescribe(env);
13388                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13389         }
13390         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13391         CHECK_ACCESS(ret_ptr);
13392         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13393         FREE((void*)ret);
13394         if (get_jenv_res == JNI_EDETACHED) {
13395                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13396         }
13397         return ret_conv;
13398 }
13399 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13400         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13401         JNIEnv *env;
13402         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13403         if (get_jenv_res == JNI_EDETACHED) {
13404                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13405         } else {
13406                 DO_ASSERT(get_jenv_res == JNI_OK);
13407         }
13408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13409         CHECK(obj != NULL);
13410         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13411         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13412                 (*env)->ExceptionDescribe(env);
13413                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13414         }
13415         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13416         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13417         if (ret_constr.datalen > 0)
13418                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13419         else
13420                 ret_constr.data = NULL;
13421         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13422         for (size_t z = 0; z < ret_constr.datalen; z++) {
13423                 int64_t ret_conv_25 = ret_vals[z];
13424                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
13425                 CHECK_ACCESS(ret_conv_25_ptr);
13426                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13427                 FREE((void*)ret_conv_25);
13428                 ret_constr.data[z] = ret_conv_25_conv;
13429         }
13430         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13431         if (get_jenv_res == JNI_EDETACHED) {
13432                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13433         }
13434         return ret_constr;
13435 }
13436 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13437         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13438         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13439         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13440 }
13441 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13442         jclass c = (*env)->GetObjectClass(env, o);
13443         CHECK(c != NULL);
13444         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13445         atomic_init(&calls->refcnt, 1);
13446         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13447         calls->o = (*env)->NewWeakGlobalRef(env, o);
13448         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13449         CHECK(calls->handle_custom_message_meth != NULL);
13450         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13451         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13452
13453         LDKCustomMessageHandler ret = {
13454                 .this_arg = (void*) calls,
13455                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13456                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13457                 .free = LDKCustomMessageHandler_JCalls_free,
13458                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13459         };
13460         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13461         return ret;
13462 }
13463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13464         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13465         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13466         return (uint64_t)res_ptr;
13467 }
13468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13469         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
13470         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
13471         DO_ASSERT((res_ptr & 1) == 0);
13472         return (int64_t)(res_ptr | 1);
13473 }
13474 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) {
13475         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13476         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13477         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13478         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
13479         CHECK_ACCESS(msg_ptr);
13480         LDKType msg_conv = *(LDKType*)(msg_ptr);
13481         if (msg_conv.free == LDKType_JCalls_free) {
13482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13483                 LDKType_JCalls_cloned(&msg_conv);
13484         }
13485         LDKPublicKey sender_node_id_ref;
13486         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13487         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13488         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13489         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13490         return (int64_t)ret_conv;
13491 }
13492
13493 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13494         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13495         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13496         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13497         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13498         int64_tArray ret_arr = NULL;
13499         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13500         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13501         for (size_t z = 0; z < ret_var.datalen; z++) {
13502                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13503                 *ret_conv_25_conv = ret_var.data[z];
13504                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
13505         }
13506         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13507         FREE(ret_var.data);
13508         return ret_arr;
13509 }
13510
13511 typedef struct LDKSocketDescriptor_JCalls {
13512         atomic_size_t refcnt;
13513         JavaVM *vm;
13514         jweak o;
13515         jmethodID send_data_meth;
13516         jmethodID disconnect_socket_meth;
13517         jmethodID eq_meth;
13518         jmethodID hash_meth;
13519 } LDKSocketDescriptor_JCalls;
13520 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13521         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13522         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13523                 JNIEnv *env;
13524                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13525                 if (get_jenv_res == JNI_EDETACHED) {
13526                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13527                 } else {
13528                         DO_ASSERT(get_jenv_res == JNI_OK);
13529                 }
13530                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13531                 if (get_jenv_res == JNI_EDETACHED) {
13532                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13533                 }
13534                 FREE(j_calls);
13535         }
13536 }
13537 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13538         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13539         JNIEnv *env;
13540         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13541         if (get_jenv_res == JNI_EDETACHED) {
13542                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13543         } else {
13544                 DO_ASSERT(get_jenv_res == JNI_OK);
13545         }
13546         LDKu8slice data_var = data;
13547         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13548         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13549         jboolean resume_read_conv = resume_read;
13550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13551         CHECK(obj != NULL);
13552         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13553         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13554                 (*env)->ExceptionDescribe(env);
13555                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13556         }
13557         if (get_jenv_res == JNI_EDETACHED) {
13558                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13559         }
13560         return ret;
13561 }
13562 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13563         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13564         JNIEnv *env;
13565         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13566         if (get_jenv_res == JNI_EDETACHED) {
13567                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13568         } else {
13569                 DO_ASSERT(get_jenv_res == JNI_OK);
13570         }
13571         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13572         CHECK(obj != NULL);
13573         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13574         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13575                 (*env)->ExceptionDescribe(env);
13576                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13577         }
13578         if (get_jenv_res == JNI_EDETACHED) {
13579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13580         }
13581 }
13582 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13583         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13584         JNIEnv *env;
13585         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13586         if (get_jenv_res == JNI_EDETACHED) {
13587                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13588         } else {
13589                 DO_ASSERT(get_jenv_res == JNI_OK);
13590         }
13591         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13592         *other_arg_clone = SocketDescriptor_clone(other_arg);
13593         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13594         CHECK(obj != NULL);
13595         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
13596         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13597                 (*env)->ExceptionDescribe(env);
13598                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13599         }
13600         if (get_jenv_res == JNI_EDETACHED) {
13601                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13602         }
13603         return ret;
13604 }
13605 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13606         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13607         JNIEnv *env;
13608         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13609         if (get_jenv_res == JNI_EDETACHED) {
13610                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13611         } else {
13612                 DO_ASSERT(get_jenv_res == JNI_OK);
13613         }
13614         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13615         CHECK(obj != NULL);
13616         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13617         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13618                 (*env)->ExceptionDescribe(env);
13619                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
13620         }
13621         if (get_jenv_res == JNI_EDETACHED) {
13622                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13623         }
13624         return ret;
13625 }
13626 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
13627         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
13628         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13629 }
13630 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
13631         jclass c = (*env)->GetObjectClass(env, o);
13632         CHECK(c != NULL);
13633         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
13634         atomic_init(&calls->refcnt, 1);
13635         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13636         calls->o = (*env)->NewWeakGlobalRef(env, o);
13637         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
13638         CHECK(calls->send_data_meth != NULL);
13639         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
13640         CHECK(calls->disconnect_socket_meth != NULL);
13641         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
13642         CHECK(calls->eq_meth != NULL);
13643         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
13644         CHECK(calls->hash_meth != NULL);
13645
13646         LDKSocketDescriptor ret = {
13647                 .this_arg = (void*) calls,
13648                 .send_data = send_data_LDKSocketDescriptor_jcall,
13649                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
13650                 .eq = eq_LDKSocketDescriptor_jcall,
13651                 .hash = hash_LDKSocketDescriptor_jcall,
13652                 .cloned = LDKSocketDescriptor_JCalls_cloned,
13653                 .free = LDKSocketDescriptor_JCalls_free,
13654         };
13655         return ret;
13656 }
13657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
13658         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13659         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
13660         return (uint64_t)res_ptr;
13661 }
13662 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) {
13663         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13665         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13666         LDKu8slice data_ref;
13667         data_ref.datalen = (*env)->GetArrayLength(env, data);
13668         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
13669         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
13670         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
13671         return ret_conv;
13672 }
13673
13674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
13675         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13676         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13677         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13678         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
13679 }
13680
13681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
13682         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13683         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13684         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13685         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
13686         return ret_conv;
13687 }
13688
13689 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
13690 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
13691 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
13692 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
13693 static jclass LDKEffectiveCapacity_Total_class = NULL;
13694 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
13695 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
13696 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
13697 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
13698 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
13699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
13700         LDKEffectiveCapacity_ExactLiquidity_class =
13701                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
13702         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
13703         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
13704         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
13705         LDKEffectiveCapacity_MaximumHTLC_class =
13706                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
13707         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
13708         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
13709         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
13710         LDKEffectiveCapacity_Total_class =
13711                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
13712         CHECK(LDKEffectiveCapacity_Total_class != NULL);
13713         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
13714         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
13715         LDKEffectiveCapacity_Infinite_class =
13716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
13717         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
13718         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
13719         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
13720         LDKEffectiveCapacity_Unknown_class =
13721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
13722         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
13723         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
13724         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
13725 }
13726 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13727         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
13728         switch(obj->tag) {
13729                 case LDKEffectiveCapacity_ExactLiquidity: {
13730                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
13731                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
13732                 }
13733                 case LDKEffectiveCapacity_MaximumHTLC: {
13734                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
13735                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
13736                 }
13737                 case LDKEffectiveCapacity_Total: {
13738                         int64_t capacity_msat_conv = obj->total.capacity_msat;
13739                         int64_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
13740                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
13741                 }
13742                 case LDKEffectiveCapacity_Infinite: {
13743                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
13744                 }
13745                 case LDKEffectiveCapacity_Unknown: {
13746                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
13747                 }
13748                 default: abort();
13749         }
13750 }
13751 typedef struct LDKLockableScore_JCalls {
13752         atomic_size_t refcnt;
13753         JavaVM *vm;
13754         jweak o;
13755         jmethodID lock_meth;
13756 } LDKLockableScore_JCalls;
13757 static void LDKLockableScore_JCalls_free(void* this_arg) {
13758         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13759         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13760                 JNIEnv *env;
13761                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13762                 if (get_jenv_res == JNI_EDETACHED) {
13763                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13764                 } else {
13765                         DO_ASSERT(get_jenv_res == JNI_OK);
13766                 }
13767                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13768                 if (get_jenv_res == JNI_EDETACHED) {
13769                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13770                 }
13771                 FREE(j_calls);
13772         }
13773 }
13774 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
13775         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13776         JNIEnv *env;
13777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13778         if (get_jenv_res == JNI_EDETACHED) {
13779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13780         } else {
13781                 DO_ASSERT(get_jenv_res == JNI_OK);
13782         }
13783         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13784         CHECK(obj != NULL);
13785         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
13786         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13787                 (*env)->ExceptionDescribe(env);
13788                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
13789         }
13790         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13791         CHECK_ACCESS(ret_ptr);
13792         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
13793         if (ret_conv.free == LDKScore_JCalls_free) {
13794                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13795                 LDKScore_JCalls_cloned(&ret_conv);
13796         }// WARNING: we may need a move here but no clone is available for LDKScore
13797         
13798         if (get_jenv_res == JNI_EDETACHED) {
13799                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13800         }
13801         return ret_conv;
13802 }
13803 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
13804         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
13805         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13806 }
13807 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
13808         jclass c = (*env)->GetObjectClass(env, o);
13809         CHECK(c != NULL);
13810         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
13811         atomic_init(&calls->refcnt, 1);
13812         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13813         calls->o = (*env)->NewWeakGlobalRef(env, o);
13814         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
13815         CHECK(calls->lock_meth != NULL);
13816
13817         LDKLockableScore ret = {
13818                 .this_arg = (void*) calls,
13819                 .lock = lock_LDKLockableScore_jcall,
13820                 .free = LDKLockableScore_JCalls_free,
13821         };
13822         return ret;
13823 }
13824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
13825         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
13826         *res_ptr = LDKLockableScore_init(env, clz, o);
13827         return (uint64_t)res_ptr;
13828 }
13829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13830         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13831         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13832         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13833         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13834         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13835         return (int64_t)ret_ret;
13836 }
13837
13838 static jclass LDKGossipSync_P2P_class = NULL;
13839 static jmethodID LDKGossipSync_P2P_meth = NULL;
13840 static jclass LDKGossipSync_Rapid_class = NULL;
13841 static jmethodID LDKGossipSync_Rapid_meth = NULL;
13842 static jclass LDKGossipSync_None_class = NULL;
13843 static jmethodID LDKGossipSync_None_meth = NULL;
13844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
13845         LDKGossipSync_P2P_class =
13846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
13847         CHECK(LDKGossipSync_P2P_class != NULL);
13848         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
13849         CHECK(LDKGossipSync_P2P_meth != NULL);
13850         LDKGossipSync_Rapid_class =
13851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
13852         CHECK(LDKGossipSync_Rapid_class != NULL);
13853         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
13854         CHECK(LDKGossipSync_Rapid_meth != NULL);
13855         LDKGossipSync_None_class =
13856                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
13857         CHECK(LDKGossipSync_None_class != NULL);
13858         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
13859         CHECK(LDKGossipSync_None_meth != NULL);
13860 }
13861 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13862         LDKGossipSync *obj = (LDKGossipSync*)(ptr & ~1);
13863         switch(obj->tag) {
13864                 case LDKGossipSync_P2P: {
13865                         LDKP2PGossipSync p2p_var = obj->p2p;
13866                         int64_t p2p_ref = 0;
13867                         CHECK((((uintptr_t)p2p_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13868                         CHECK((((uintptr_t)&p2p_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13869                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
13870                         p2p_ref = (uintptr_t)p2p_var.inner & ~1;
13871                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
13872                 }
13873                 case LDKGossipSync_Rapid: {
13874                         LDKRapidGossipSync rapid_var = obj->rapid;
13875                         int64_t rapid_ref = 0;
13876                         CHECK((((uintptr_t)rapid_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13877                         CHECK((((uintptr_t)&rapid_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13878                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
13879                         rapid_ref = (uintptr_t)rapid_var.inner & ~1;
13880                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
13881                 }
13882                 case LDKGossipSync_None: {
13883                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
13884                 }
13885                 default: abort();
13886         }
13887 }
13888 static jclass LDKFallback_SegWitProgram_class = NULL;
13889 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13890 static jclass LDKFallback_PubKeyHash_class = NULL;
13891 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13892 static jclass LDKFallback_ScriptHash_class = NULL;
13893 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13895         LDKFallback_SegWitProgram_class =
13896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13897         CHECK(LDKFallback_SegWitProgram_class != NULL);
13898         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13899         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13900         LDKFallback_PubKeyHash_class =
13901                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13902         CHECK(LDKFallback_PubKeyHash_class != NULL);
13903         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13904         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13905         LDKFallback_ScriptHash_class =
13906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13907         CHECK(LDKFallback_ScriptHash_class != NULL);
13908         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13909         CHECK(LDKFallback_ScriptHash_meth != NULL);
13910 }
13911 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13912         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13913         switch(obj->tag) {
13914                 case LDKFallback_SegWitProgram: {
13915                         uint8_t version_val = obj->seg_wit_program.version._0;
13916                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13917                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13918                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13919                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13920                 }
13921                 case LDKFallback_PubKeyHash: {
13922                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13923                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13924                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13925                 }
13926                 case LDKFallback_ScriptHash: {
13927                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13928                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13929                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13930                 }
13931                 default: abort();
13932         }
13933 }
13934 typedef struct LDKPayer_JCalls {
13935         atomic_size_t refcnt;
13936         JavaVM *vm;
13937         jweak o;
13938         jmethodID node_id_meth;
13939         jmethodID first_hops_meth;
13940         jmethodID send_payment_meth;
13941         jmethodID send_spontaneous_payment_meth;
13942         jmethodID retry_payment_meth;
13943         jmethodID abandon_payment_meth;
13944 } LDKPayer_JCalls;
13945 static void LDKPayer_JCalls_free(void* this_arg) {
13946         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13947         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13948                 JNIEnv *env;
13949                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13950                 if (get_jenv_res == JNI_EDETACHED) {
13951                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13952                 } else {
13953                         DO_ASSERT(get_jenv_res == JNI_OK);
13954                 }
13955                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13956                 if (get_jenv_res == JNI_EDETACHED) {
13957                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13958                 }
13959                 FREE(j_calls);
13960         }
13961 }
13962 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13963         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13964         JNIEnv *env;
13965         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13966         if (get_jenv_res == JNI_EDETACHED) {
13967                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13968         } else {
13969                 DO_ASSERT(get_jenv_res == JNI_OK);
13970         }
13971         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13972         CHECK(obj != NULL);
13973         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13974         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13975                 (*env)->ExceptionDescribe(env);
13976                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13977         }
13978         LDKPublicKey ret_ref;
13979         CHECK((*env)->GetArrayLength(env, ret) == 33);
13980         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13981         if (get_jenv_res == JNI_EDETACHED) {
13982                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13983         }
13984         return ret_ref;
13985 }
13986 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13987         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13988         JNIEnv *env;
13989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13990         if (get_jenv_res == JNI_EDETACHED) {
13991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13992         } else {
13993                 DO_ASSERT(get_jenv_res == JNI_OK);
13994         }
13995         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13996         CHECK(obj != NULL);
13997         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13998         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13999                 (*env)->ExceptionDescribe(env);
14000                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14001         }
14002         LDKCVec_ChannelDetailsZ ret_constr;
14003         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14004         if (ret_constr.datalen > 0)
14005                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14006         else
14007                 ret_constr.data = NULL;
14008         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14009         for (size_t q = 0; q < ret_constr.datalen; q++) {
14010                 int64_t ret_conv_16 = ret_vals[q];
14011                 LDKChannelDetails ret_conv_16_conv;
14012                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
14013                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
14014                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14015                 ret_constr.data[q] = ret_conv_16_conv;
14016         }
14017         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14018         if (get_jenv_res == JNI_EDETACHED) {
14019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14020         }
14021         return ret_constr;
14022 }
14023 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14024         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14025         JNIEnv *env;
14026         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14027         if (get_jenv_res == JNI_EDETACHED) {
14028                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14029         } else {
14030                 DO_ASSERT(get_jenv_res == JNI_OK);
14031         }
14032         LDKRoute route_var = *route;
14033         int64_t route_ref = 0;
14034         route_var = Route_clone(&route_var);
14035         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14036         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14037         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14038         route_ref = (uintptr_t)route_var.inner;
14039         if (route_var.is_owned) {
14040                 route_ref |= 1;
14041         }
14042         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14043         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14044         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14045         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14047         CHECK(obj != NULL);
14048         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14049         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14050                 (*env)->ExceptionDescribe(env);
14051                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14052         }
14053         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14054         CHECK_ACCESS(ret_ptr);
14055         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14056         FREE((void*)ret);
14057         if (get_jenv_res == JNI_EDETACHED) {
14058                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14059         }
14060         return ret_conv;
14061 }
14062 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14063         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14064         JNIEnv *env;
14065         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14066         if (get_jenv_res == JNI_EDETACHED) {
14067                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14068         } else {
14069                 DO_ASSERT(get_jenv_res == JNI_OK);
14070         }
14071         LDKRoute route_var = *route;
14072         int64_t route_ref = 0;
14073         route_var = Route_clone(&route_var);
14074         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14075         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14076         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14077         route_ref = (uintptr_t)route_var.inner;
14078         if (route_var.is_owned) {
14079                 route_ref |= 1;
14080         }
14081         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14082         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14083         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14084         CHECK(obj != NULL);
14085         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14086         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14087                 (*env)->ExceptionDescribe(env);
14088                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14089         }
14090         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14091         CHECK_ACCESS(ret_ptr);
14092         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14093         FREE((void*)ret);
14094         if (get_jenv_res == JNI_EDETACHED) {
14095                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14096         }
14097         return ret_conv;
14098 }
14099 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14100         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14101         JNIEnv *env;
14102         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14103         if (get_jenv_res == JNI_EDETACHED) {
14104                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14105         } else {
14106                 DO_ASSERT(get_jenv_res == JNI_OK);
14107         }
14108         LDKRoute route_var = *route;
14109         int64_t route_ref = 0;
14110         route_var = Route_clone(&route_var);
14111         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14112         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14113         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14114         route_ref = (uintptr_t)route_var.inner;
14115         if (route_var.is_owned) {
14116                 route_ref |= 1;
14117         }
14118         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14119         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14120         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14121         CHECK(obj != NULL);
14122         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14123         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14124                 (*env)->ExceptionDescribe(env);
14125                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14126         }
14127         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14128         CHECK_ACCESS(ret_ptr);
14129         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14130         FREE((void*)ret);
14131         if (get_jenv_res == JNI_EDETACHED) {
14132                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14133         }
14134         return ret_conv;
14135 }
14136 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14137         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14138         JNIEnv *env;
14139         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14140         if (get_jenv_res == JNI_EDETACHED) {
14141                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14142         } else {
14143                 DO_ASSERT(get_jenv_res == JNI_OK);
14144         }
14145         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14146         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14147         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14148         CHECK(obj != NULL);
14149         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14150         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14151                 (*env)->ExceptionDescribe(env);
14152                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14153         }
14154         if (get_jenv_res == JNI_EDETACHED) {
14155                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14156         }
14157 }
14158 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14159         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14160         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14161 }
14162 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14163         jclass c = (*env)->GetObjectClass(env, o);
14164         CHECK(c != NULL);
14165         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14166         atomic_init(&calls->refcnt, 1);
14167         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14168         calls->o = (*env)->NewWeakGlobalRef(env, o);
14169         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14170         CHECK(calls->node_id_meth != NULL);
14171         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14172         CHECK(calls->first_hops_meth != NULL);
14173         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14174         CHECK(calls->send_payment_meth != NULL);
14175         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14176         CHECK(calls->send_spontaneous_payment_meth != NULL);
14177         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14178         CHECK(calls->retry_payment_meth != NULL);
14179         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14180         CHECK(calls->abandon_payment_meth != NULL);
14181
14182         LDKPayer ret = {
14183                 .this_arg = (void*) calls,
14184                 .node_id = node_id_LDKPayer_jcall,
14185                 .first_hops = first_hops_LDKPayer_jcall,
14186                 .send_payment = send_payment_LDKPayer_jcall,
14187                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14188                 .retry_payment = retry_payment_LDKPayer_jcall,
14189                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14190                 .free = LDKPayer_JCalls_free,
14191         };
14192         return ret;
14193 }
14194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14195         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14196         *res_ptr = LDKPayer_init(env, clz, o);
14197         return (uint64_t)res_ptr;
14198 }
14199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14202         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14203         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14205         return ret_arr;
14206 }
14207
14208 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14209         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14210         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14211         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14212         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14213         int64_tArray ret_arr = NULL;
14214         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14215         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14216         for (size_t q = 0; q < ret_var.datalen; q++) {
14217                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14218                 int64_t ret_conv_16_ref = 0;
14219                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14220                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14221                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14222                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
14223                 if (ret_conv_16_var.is_owned) {
14224                         ret_conv_16_ref |= 1;
14225                 }
14226                 ret_arr_ptr[q] = ret_conv_16_ref;
14227         }
14228         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14229         FREE(ret_var.data);
14230         return ret_arr;
14231 }
14232
14233 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) {
14234         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14235         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14236         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14237         LDKRoute route_conv;
14238         route_conv.inner = (void*)(route & (~1));
14239         route_conv.is_owned = false;
14240         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14241         LDKThirtyTwoBytes payment_hash_ref;
14242         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14243         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14244         LDKThirtyTwoBytes payment_secret_ref;
14245         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14246         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14247         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14248         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14249         return (int64_t)ret_conv;
14250 }
14251
14252 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) {
14253         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14254         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14255         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14256         LDKRoute route_conv;
14257         route_conv.inner = (void*)(route & (~1));
14258         route_conv.is_owned = false;
14259         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14260         LDKThirtyTwoBytes payment_preimage_ref;
14261         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14262         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14263         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14264         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14265         return (int64_t)ret_conv;
14266 }
14267
14268 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) {
14269         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14270         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14271         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14272         LDKRoute route_conv;
14273         route_conv.inner = (void*)(route & (~1));
14274         route_conv.is_owned = false;
14275         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14276         LDKThirtyTwoBytes payment_id_ref;
14277         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14278         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14279         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14280         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14281         return (int64_t)ret_conv;
14282 }
14283
14284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14285         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14287         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14288         LDKThirtyTwoBytes payment_id_ref;
14289         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14290         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14291         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14292 }
14293
14294 typedef struct LDKRouter_JCalls {
14295         atomic_size_t refcnt;
14296         JavaVM *vm;
14297         jweak o;
14298         jmethodID find_route_meth;
14299 } LDKRouter_JCalls;
14300 static void LDKRouter_JCalls_free(void* this_arg) {
14301         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14302         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14303                 JNIEnv *env;
14304                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14305                 if (get_jenv_res == JNI_EDETACHED) {
14306                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14307                 } else {
14308                         DO_ASSERT(get_jenv_res == JNI_OK);
14309                 }
14310                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14311                 if (get_jenv_res == JNI_EDETACHED) {
14312                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14313                 }
14314                 FREE(j_calls);
14315         }
14316 }
14317 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) {
14318         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14319         JNIEnv *env;
14320         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14321         if (get_jenv_res == JNI_EDETACHED) {
14322                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14323         } else {
14324                 DO_ASSERT(get_jenv_res == JNI_OK);
14325         }
14326         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14327         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14328         LDKRouteParameters route_params_var = *route_params;
14329         int64_t route_params_ref = 0;
14330         route_params_var = RouteParameters_clone(&route_params_var);
14331         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14332         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14333         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14334         route_params_ref = (uintptr_t)route_params_var.inner;
14335         if (route_params_var.is_owned) {
14336                 route_params_ref |= 1;
14337         }
14338         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14339         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14340         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14341         int64_tArray first_hops_arr = NULL;
14342         if (first_hops != NULL) {
14343                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14344                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14345                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14346                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14347                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14348                         int64_t first_hops_conv_16_ref = 0;
14349                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14350                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14351                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14352                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
14353                         if (first_hops_conv_16_var.is_owned) {
14354                                 first_hops_conv_16_ref |= 1;
14355                         }
14356                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14357                 }
14358                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14359         }
14360         // WARNING: This object doesn't live past this scope, needs clone!
14361         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
14362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14363         CHECK(obj != NULL);
14364         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);
14365         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14366                 (*env)->ExceptionDescribe(env);
14367                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14368         }
14369         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14370         CHECK_ACCESS(ret_ptr);
14371         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14372         FREE((void*)ret);
14373         if (get_jenv_res == JNI_EDETACHED) {
14374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14375         }
14376         return ret_conv;
14377 }
14378 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14379         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14380         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14381 }
14382 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14383         jclass c = (*env)->GetObjectClass(env, o);
14384         CHECK(c != NULL);
14385         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14386         atomic_init(&calls->refcnt, 1);
14387         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14388         calls->o = (*env)->NewWeakGlobalRef(env, o);
14389         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14390         CHECK(calls->find_route_meth != NULL);
14391
14392         LDKRouter ret = {
14393                 .this_arg = (void*) calls,
14394                 .find_route = find_route_LDKRouter_jcall,
14395                 .free = LDKRouter_JCalls_free,
14396         };
14397         return ret;
14398 }
14399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14400         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14401         *res_ptr = LDKRouter_init(env, clz, o);
14402         return (uint64_t)res_ptr;
14403 }
14404 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) {
14405         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14407         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14408         LDKPublicKey payer_ref;
14409         CHECK((*env)->GetArrayLength(env, payer) == 33);
14410         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14411         LDKRouteParameters route_params_conv;
14412         route_params_conv.inner = (void*)(route_params & (~1));
14413         route_params_conv.is_owned = false;
14414         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14415         unsigned char payment_hash_arr[32];
14416         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14417         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14418         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14419         LDKCVec_ChannelDetailsZ first_hops_constr;
14420         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14421         if (first_hops != NULL) {
14422                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14423                 if (first_hops_constr.datalen > 0)
14424                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14425                 else
14426                         first_hops_constr.data = NULL;
14427                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14428                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14429                         int64_t first_hops_conv_16 = first_hops_vals[q];
14430                         LDKChannelDetails first_hops_conv_16_conv;
14431                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14432                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14433                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14434                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14435                 }
14436                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14437                 first_hops_ptr = &first_hops_constr;
14438         }
14439         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14440         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14441         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14442         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14443         *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);
14444         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14445         return (int64_t)ret_conv;
14446 }
14447
14448 static jclass LDKRetry_Attempts_class = NULL;
14449 static jmethodID LDKRetry_Attempts_meth = NULL;
14450 static jclass LDKRetry_Timeout_class = NULL;
14451 static jmethodID LDKRetry_Timeout_meth = NULL;
14452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
14453         LDKRetry_Attempts_class =
14454                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
14455         CHECK(LDKRetry_Attempts_class != NULL);
14456         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
14457         CHECK(LDKRetry_Attempts_meth != NULL);
14458         LDKRetry_Timeout_class =
14459                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
14460         CHECK(LDKRetry_Timeout_class != NULL);
14461         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
14462         CHECK(LDKRetry_Timeout_meth != NULL);
14463 }
14464 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14465         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
14466         switch(obj->tag) {
14467                 case LDKRetry_Attempts: {
14468                         int64_t attempts_conv = obj->attempts;
14469                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
14470                 }
14471                 case LDKRetry_Timeout: {
14472                         int64_t timeout_conv = obj->timeout;
14473                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
14474                 }
14475                 default: abort();
14476         }
14477 }
14478 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14479         LDKStr ret_str = _ldk_get_compiled_version();
14480         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14481         Str_free(ret_str);
14482         return ret_conv;
14483 }
14484
14485 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14486         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14487         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14488         Str_free(ret_str);
14489         return ret_conv;
14490 }
14491
14492 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14493         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14494         *ret_copy = Bech32Error_clone(arg);
14495 int64_t ret_ref = (uintptr_t)ret_copy;
14496         return ret_ref;
14497 }
14498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14499         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14500         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14501         return ret_conv;
14502 }
14503
14504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14505         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14506         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14507         *ret_copy = Bech32Error_clone(orig_conv);
14508         int64_t ret_ref = (uintptr_t)ret_copy;
14509         return ret_ref;
14510 }
14511
14512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14513         if ((o & 1) != 0) return;
14514         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14515         CHECK_ACCESS(o_ptr);
14516         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14517         FREE((void*)o);
14518         Bech32Error_free(o_conv);
14519 }
14520
14521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14522         LDKTransaction _res_ref;
14523         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14524         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14525         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14526         _res_ref.data_is_owned = true;
14527         Transaction_free(_res_ref);
14528 }
14529
14530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14531         LDKCVec_u8Z script_pubkey_ref;
14532         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14533         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14534         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14535         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14536         *ret_ref = TxOut_new(script_pubkey_ref, value);
14537         return (int64_t)ret_ref;
14538 }
14539
14540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14541         if ((_res & 1) != 0) return;
14542         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14543         CHECK_ACCESS(_res_ptr);
14544         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14545         FREE((void*)_res);
14546         TxOut_free(_res_conv);
14547 }
14548
14549 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14550         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14551         *ret_ref = TxOut_clone(arg);
14552         return (int64_t)ret_ref;
14553 }
14554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14555         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14556         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14557         return ret_conv;
14558 }
14559
14560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14561         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14562         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14563         *ret_ref = TxOut_clone(orig_conv);
14564         return (int64_t)ret_ref;
14565 }
14566
14567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14568         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14569         Str_free(dummy);
14570 }
14571
14572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14573         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14574         *ret_conv = CResult_NoneNoneZ_ok();
14575         return (int64_t)ret_conv;
14576 }
14577
14578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14579         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14580         *ret_conv = CResult_NoneNoneZ_err();
14581         return (int64_t)ret_conv;
14582 }
14583
14584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14585         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14586         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14587         return ret_conv;
14588 }
14589
14590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14591         if ((_res & 1) != 0) return;
14592         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14593         CHECK_ACCESS(_res_ptr);
14594         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14595         FREE((void*)_res);
14596         CResult_NoneNoneZ_free(_res_conv);
14597 }
14598
14599 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14600         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14601         *ret_conv = CResult_NoneNoneZ_clone(arg);
14602         return (int64_t)ret_conv;
14603 }
14604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14605         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14606         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14607         return ret_conv;
14608 }
14609
14610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14611         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14612         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14613         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14614         return (int64_t)ret_conv;
14615 }
14616
14617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14618         LDKCounterpartyCommitmentSecrets o_conv;
14619         o_conv.inner = (void*)(o & (~1));
14620         o_conv.is_owned = (o & 1) || (o == 0);
14621         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14622         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14623         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14624         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14625         return (int64_t)ret_conv;
14626 }
14627
14628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14629         LDKDecodeError e_conv;
14630         e_conv.inner = (void*)(e & (~1));
14631         e_conv.is_owned = (e & 1) || (e == 0);
14632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14633         e_conv = DecodeError_clone(&e_conv);
14634         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14635         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14636         return (int64_t)ret_conv;
14637 }
14638
14639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14640         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14641         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14642         return ret_conv;
14643 }
14644
14645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14646         if ((_res & 1) != 0) return;
14647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14648         CHECK_ACCESS(_res_ptr);
14649         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14650         FREE((void*)_res);
14651         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14652 }
14653
14654 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14655         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14656         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14657         return (int64_t)ret_conv;
14658 }
14659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14660         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14661         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14662         return ret_conv;
14663 }
14664
14665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14666         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14667         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14668         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
14669         return (int64_t)ret_conv;
14670 }
14671
14672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14673         LDKSecretKey o_ref;
14674         CHECK((*env)->GetArrayLength(env, o) == 32);
14675         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
14676         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14677         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
14678         return (int64_t)ret_conv;
14679 }
14680
14681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14682         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14683         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14684         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
14685         return (int64_t)ret_conv;
14686 }
14687
14688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14689         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
14690         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
14691         return ret_conv;
14692 }
14693
14694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14695         if ((_res & 1) != 0) return;
14696         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14697         CHECK_ACCESS(_res_ptr);
14698         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
14699         FREE((void*)_res);
14700         CResult_SecretKeyErrorZ_free(_res_conv);
14701 }
14702
14703 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
14704         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14705         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
14706         return (int64_t)ret_conv;
14707 }
14708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14709         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
14710         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
14711         return ret_conv;
14712 }
14713
14714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14715         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
14716         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14717         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
14718         return (int64_t)ret_conv;
14719 }
14720
14721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14722         LDKPublicKey o_ref;
14723         CHECK((*env)->GetArrayLength(env, o) == 33);
14724         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
14725         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14726         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
14727         return (int64_t)ret_conv;
14728 }
14729
14730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14731         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14732         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14733         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
14734         return (int64_t)ret_conv;
14735 }
14736
14737 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14738         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
14739         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
14740         return ret_conv;
14741 }
14742
14743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14744         if ((_res & 1) != 0) return;
14745         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14746         CHECK_ACCESS(_res_ptr);
14747         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
14748         FREE((void*)_res);
14749         CResult_PublicKeyErrorZ_free(_res_conv);
14750 }
14751
14752 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
14753         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14754         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
14755         return (int64_t)ret_conv;
14756 }
14757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14758         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
14759         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
14760         return ret_conv;
14761 }
14762
14763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14764         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
14765         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14766         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
14767         return (int64_t)ret_conv;
14768 }
14769
14770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14771         LDKTxCreationKeys o_conv;
14772         o_conv.inner = (void*)(o & (~1));
14773         o_conv.is_owned = (o & 1) || (o == 0);
14774         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14775         o_conv = TxCreationKeys_clone(&o_conv);
14776         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14777         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
14778         return (int64_t)ret_conv;
14779 }
14780
14781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14782         LDKDecodeError e_conv;
14783         e_conv.inner = (void*)(e & (~1));
14784         e_conv.is_owned = (e & 1) || (e == 0);
14785         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14786         e_conv = DecodeError_clone(&e_conv);
14787         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14788         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
14789         return (int64_t)ret_conv;
14790 }
14791
14792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14793         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
14794         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
14795         return ret_conv;
14796 }
14797
14798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14799         if ((_res & 1) != 0) return;
14800         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14801         CHECK_ACCESS(_res_ptr);
14802         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
14803         FREE((void*)_res);
14804         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
14805 }
14806
14807 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
14808         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14809         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
14810         return (int64_t)ret_conv;
14811 }
14812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14813         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
14814         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
14815         return ret_conv;
14816 }
14817
14818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14819         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
14820         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14821         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
14822         return (int64_t)ret_conv;
14823 }
14824
14825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14826         LDKChannelPublicKeys o_conv;
14827         o_conv.inner = (void*)(o & (~1));
14828         o_conv.is_owned = (o & 1) || (o == 0);
14829         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14830         o_conv = ChannelPublicKeys_clone(&o_conv);
14831         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14832         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
14833         return (int64_t)ret_conv;
14834 }
14835
14836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14837         LDKDecodeError e_conv;
14838         e_conv.inner = (void*)(e & (~1));
14839         e_conv.is_owned = (e & 1) || (e == 0);
14840         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14841         e_conv = DecodeError_clone(&e_conv);
14842         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14843         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14844         return (int64_t)ret_conv;
14845 }
14846
14847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14848         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14849         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14850         return ret_conv;
14851 }
14852
14853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14854         if ((_res & 1) != 0) return;
14855         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14856         CHECK_ACCESS(_res_ptr);
14857         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14858         FREE((void*)_res);
14859         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14860 }
14861
14862 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14863         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14864         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14865         return (int64_t)ret_conv;
14866 }
14867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14868         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14869         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14870         return ret_conv;
14871 }
14872
14873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14874         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14875         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14876         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14877         return (int64_t)ret_conv;
14878 }
14879
14880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14881         LDKTxCreationKeys o_conv;
14882         o_conv.inner = (void*)(o & (~1));
14883         o_conv.is_owned = (o & 1) || (o == 0);
14884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14885         o_conv = TxCreationKeys_clone(&o_conv);
14886         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14887         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14888         return (int64_t)ret_conv;
14889 }
14890
14891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14892         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14893         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14894         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14895         return (int64_t)ret_conv;
14896 }
14897
14898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14899         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14900         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14901         return ret_conv;
14902 }
14903
14904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14905         if ((_res & 1) != 0) return;
14906         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14907         CHECK_ACCESS(_res_ptr);
14908         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14909         FREE((void*)_res);
14910         CResult_TxCreationKeysErrorZ_free(_res_conv);
14911 }
14912
14913 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14914         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14915         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14916         return (int64_t)ret_conv;
14917 }
14918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14919         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14920         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14921         return ret_conv;
14922 }
14923
14924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14925         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14926         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14927         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14928         return (int64_t)ret_conv;
14929 }
14930
14931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14932         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14933         *ret_copy = COption_u32Z_some(o);
14934         int64_t ret_ref = (uintptr_t)ret_copy;
14935         return ret_ref;
14936 }
14937
14938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14939         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14940         *ret_copy = COption_u32Z_none();
14941         int64_t ret_ref = (uintptr_t)ret_copy;
14942         return ret_ref;
14943 }
14944
14945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14946         if ((_res & 1) != 0) return;
14947         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14948         CHECK_ACCESS(_res_ptr);
14949         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14950         FREE((void*)_res);
14951         COption_u32Z_free(_res_conv);
14952 }
14953
14954 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14955         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14956         *ret_copy = COption_u32Z_clone(arg);
14957 int64_t ret_ref = (uintptr_t)ret_copy;
14958         return ret_ref;
14959 }
14960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14961         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14962         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
14963         return ret_conv;
14964 }
14965
14966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14967         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14968         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14969         *ret_copy = COption_u32Z_clone(orig_conv);
14970         int64_t ret_ref = (uintptr_t)ret_copy;
14971         return ret_ref;
14972 }
14973
14974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14975         LDKHTLCOutputInCommitment o_conv;
14976         o_conv.inner = (void*)(o & (~1));
14977         o_conv.is_owned = (o & 1) || (o == 0);
14978         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14979         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14980         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14981         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14982         return (int64_t)ret_conv;
14983 }
14984
14985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14986         LDKDecodeError e_conv;
14987         e_conv.inner = (void*)(e & (~1));
14988         e_conv.is_owned = (e & 1) || (e == 0);
14989         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14990         e_conv = DecodeError_clone(&e_conv);
14991         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14992         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14993         return (int64_t)ret_conv;
14994 }
14995
14996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14997         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14998         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14999         return ret_conv;
15000 }
15001
15002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15003         if ((_res & 1) != 0) return;
15004         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15005         CHECK_ACCESS(_res_ptr);
15006         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15007         FREE((void*)_res);
15008         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15009 }
15010
15011 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15012         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15013         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
15014         return (int64_t)ret_conv;
15015 }
15016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15017         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
15018         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
15019         return ret_conv;
15020 }
15021
15022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15023         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
15024         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15025         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
15026         return (int64_t)ret_conv;
15027 }
15028
15029 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
15030         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
15031         return ret_conv;
15032 }
15033
15034 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
15035         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
15036         return ret_conv;
15037 }
15038
15039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
15040         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
15041         COption_NoneZ_free(_res_conv);
15042 }
15043
15044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15045         LDKCounterpartyChannelTransactionParameters o_conv;
15046         o_conv.inner = (void*)(o & (~1));
15047         o_conv.is_owned = (o & 1) || (o == 0);
15048         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15049         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
15050         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15051         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15052         return (int64_t)ret_conv;
15053 }
15054
15055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15056         LDKDecodeError e_conv;
15057         e_conv.inner = (void*)(e & (~1));
15058         e_conv.is_owned = (e & 1) || (e == 0);
15059         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15060         e_conv = DecodeError_clone(&e_conv);
15061         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15062         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
15063         return (int64_t)ret_conv;
15064 }
15065
15066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15067         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15068         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15069         return ret_conv;
15070 }
15071
15072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15073         if ((_res & 1) != 0) return;
15074         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15075         CHECK_ACCESS(_res_ptr);
15076         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15077         FREE((void*)_res);
15078         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15079 }
15080
15081 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15082         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15083         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
15084         return (int64_t)ret_conv;
15085 }
15086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15087         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15088         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15089         return ret_conv;
15090 }
15091
15092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15093         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15094         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15095         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15096         return (int64_t)ret_conv;
15097 }
15098
15099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15100         LDKChannelTransactionParameters o_conv;
15101         o_conv.inner = (void*)(o & (~1));
15102         o_conv.is_owned = (o & 1) || (o == 0);
15103         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15104         o_conv = ChannelTransactionParameters_clone(&o_conv);
15105         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15106         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15107         return (int64_t)ret_conv;
15108 }
15109
15110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15111         LDKDecodeError e_conv;
15112         e_conv.inner = (void*)(e & (~1));
15113         e_conv.is_owned = (e & 1) || (e == 0);
15114         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15115         e_conv = DecodeError_clone(&e_conv);
15116         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15117         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15118         return (int64_t)ret_conv;
15119 }
15120
15121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15122         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15123         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15124         return ret_conv;
15125 }
15126
15127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15128         if ((_res & 1) != 0) return;
15129         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15130         CHECK_ACCESS(_res_ptr);
15131         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15132         FREE((void*)_res);
15133         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15134 }
15135
15136 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15137         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15138         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15139         return (int64_t)ret_conv;
15140 }
15141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15142         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15143         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15144         return ret_conv;
15145 }
15146
15147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15148         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15149         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15150         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15151         return (int64_t)ret_conv;
15152 }
15153
15154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15155         LDKCVec_SignatureZ _res_constr;
15156         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15157         if (_res_constr.datalen > 0)
15158                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15159         else
15160                 _res_constr.data = NULL;
15161         for (size_t i = 0; i < _res_constr.datalen; i++) {
15162                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15163                 LDKSignature _res_conv_8_ref;
15164                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15165                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15166                 _res_constr.data[i] = _res_conv_8_ref;
15167         }
15168         CVec_SignatureZ_free(_res_constr);
15169 }
15170
15171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15172         LDKHolderCommitmentTransaction o_conv;
15173         o_conv.inner = (void*)(o & (~1));
15174         o_conv.is_owned = (o & 1) || (o == 0);
15175         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15176         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15177         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15178         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15179         return (int64_t)ret_conv;
15180 }
15181
15182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15183         LDKDecodeError e_conv;
15184         e_conv.inner = (void*)(e & (~1));
15185         e_conv.is_owned = (e & 1) || (e == 0);
15186         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15187         e_conv = DecodeError_clone(&e_conv);
15188         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15189         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15190         return (int64_t)ret_conv;
15191 }
15192
15193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15194         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
15195         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15196         return ret_conv;
15197 }
15198
15199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15200         if ((_res & 1) != 0) return;
15201         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15202         CHECK_ACCESS(_res_ptr);
15203         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15204         FREE((void*)_res);
15205         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15206 }
15207
15208 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15209         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15210         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15211         return (int64_t)ret_conv;
15212 }
15213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15214         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15215         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15216         return ret_conv;
15217 }
15218
15219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15220         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15221         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15222         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15223         return (int64_t)ret_conv;
15224 }
15225
15226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15227         LDKBuiltCommitmentTransaction o_conv;
15228         o_conv.inner = (void*)(o & (~1));
15229         o_conv.is_owned = (o & 1) || (o == 0);
15230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15231         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15232         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15233         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15234         return (int64_t)ret_conv;
15235 }
15236
15237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15238         LDKDecodeError e_conv;
15239         e_conv.inner = (void*)(e & (~1));
15240         e_conv.is_owned = (e & 1) || (e == 0);
15241         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15242         e_conv = DecodeError_clone(&e_conv);
15243         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15244         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15245         return (int64_t)ret_conv;
15246 }
15247
15248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15249         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
15250         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15251         return ret_conv;
15252 }
15253
15254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15255         if ((_res & 1) != 0) return;
15256         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15257         CHECK_ACCESS(_res_ptr);
15258         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15259         FREE((void*)_res);
15260         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15261 }
15262
15263 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15264         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15265         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15266         return (int64_t)ret_conv;
15267 }
15268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15269         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15270         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15271         return ret_conv;
15272 }
15273
15274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15275         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15276         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15277         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15278         return (int64_t)ret_conv;
15279 }
15280
15281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15282         LDKTrustedClosingTransaction o_conv;
15283         o_conv.inner = (void*)(o & (~1));
15284         o_conv.is_owned = (o & 1) || (o == 0);
15285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15286         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15287         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15288         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15289         return (int64_t)ret_conv;
15290 }
15291
15292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15293         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15294         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15295         return (int64_t)ret_conv;
15296 }
15297
15298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15299         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
15300         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15301         return ret_conv;
15302 }
15303
15304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15305         if ((_res & 1) != 0) return;
15306         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15307         CHECK_ACCESS(_res_ptr);
15308         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15309         FREE((void*)_res);
15310         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15311 }
15312
15313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15314         LDKCommitmentTransaction o_conv;
15315         o_conv.inner = (void*)(o & (~1));
15316         o_conv.is_owned = (o & 1) || (o == 0);
15317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15318         o_conv = CommitmentTransaction_clone(&o_conv);
15319         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15320         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
15321         return (int64_t)ret_conv;
15322 }
15323
15324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15325         LDKDecodeError e_conv;
15326         e_conv.inner = (void*)(e & (~1));
15327         e_conv.is_owned = (e & 1) || (e == 0);
15328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15329         e_conv = DecodeError_clone(&e_conv);
15330         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15331         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
15332         return (int64_t)ret_conv;
15333 }
15334
15335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15336         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
15337         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15338         return ret_conv;
15339 }
15340
15341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15342         if ((_res & 1) != 0) return;
15343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15344         CHECK_ACCESS(_res_ptr);
15345         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
15346         FREE((void*)_res);
15347         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
15348 }
15349
15350 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15351         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15352         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
15353         return (int64_t)ret_conv;
15354 }
15355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15356         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
15357         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15358         return ret_conv;
15359 }
15360
15361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15362         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
15363         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15364         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
15365         return (int64_t)ret_conv;
15366 }
15367
15368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15369         LDKTrustedCommitmentTransaction o_conv;
15370         o_conv.inner = (void*)(o & (~1));
15371         o_conv.is_owned = (o & 1) || (o == 0);
15372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15373         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
15374         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15375         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
15376         return (int64_t)ret_conv;
15377 }
15378
15379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15380         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15381         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
15382         return (int64_t)ret_conv;
15383 }
15384
15385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15386         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
15387         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
15388         return ret_conv;
15389 }
15390
15391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15392         if ((_res & 1) != 0) return;
15393         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15394         CHECK_ACCESS(_res_ptr);
15395         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
15396         FREE((void*)_res);
15397         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
15398 }
15399
15400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15401         LDKCVec_SignatureZ o_constr;
15402         o_constr.datalen = (*env)->GetArrayLength(env, o);
15403         if (o_constr.datalen > 0)
15404                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15405         else
15406                 o_constr.data = NULL;
15407         for (size_t i = 0; i < o_constr.datalen; i++) {
15408                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15409                 LDKSignature o_conv_8_ref;
15410                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15411                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15412                 o_constr.data[i] = o_conv_8_ref;
15413         }
15414         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15415         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15416         return (int64_t)ret_conv;
15417 }
15418
15419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15420         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15421         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15422         return (int64_t)ret_conv;
15423 }
15424
15425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15426         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15427         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15428         return ret_conv;
15429 }
15430
15431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15432         if ((_res & 1) != 0) return;
15433         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15434         CHECK_ACCESS(_res_ptr);
15435         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15436         FREE((void*)_res);
15437         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15438 }
15439
15440 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15441         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15442         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15443         return (int64_t)ret_conv;
15444 }
15445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15446         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15447         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15448         return ret_conv;
15449 }
15450
15451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15452         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15453         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15454         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15455         return (int64_t)ret_conv;
15456 }
15457
15458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15459         LDKShutdownScript o_conv;
15460         o_conv.inner = (void*)(o & (~1));
15461         o_conv.is_owned = (o & 1) || (o == 0);
15462         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15463         o_conv = ShutdownScript_clone(&o_conv);
15464         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15465         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15466         return (int64_t)ret_conv;
15467 }
15468
15469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15470         LDKDecodeError e_conv;
15471         e_conv.inner = (void*)(e & (~1));
15472         e_conv.is_owned = (e & 1) || (e == 0);
15473         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15474         e_conv = DecodeError_clone(&e_conv);
15475         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15476         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15477         return (int64_t)ret_conv;
15478 }
15479
15480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15481         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15482         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15483         return ret_conv;
15484 }
15485
15486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15487         if ((_res & 1) != 0) return;
15488         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15489         CHECK_ACCESS(_res_ptr);
15490         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15491         FREE((void*)_res);
15492         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15493 }
15494
15495 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15496         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15497         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15498         return (int64_t)ret_conv;
15499 }
15500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15501         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15502         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15503         return ret_conv;
15504 }
15505
15506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15507         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15508         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15509         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15510         return (int64_t)ret_conv;
15511 }
15512
15513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15514         LDKShutdownScript o_conv;
15515         o_conv.inner = (void*)(o & (~1));
15516         o_conv.is_owned = (o & 1) || (o == 0);
15517         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15518         o_conv = ShutdownScript_clone(&o_conv);
15519         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15520         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15521         return (int64_t)ret_conv;
15522 }
15523
15524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15525         LDKInvalidShutdownScript e_conv;
15526         e_conv.inner = (void*)(e & (~1));
15527         e_conv.is_owned = (e & 1) || (e == 0);
15528         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15529         e_conv = InvalidShutdownScript_clone(&e_conv);
15530         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15531         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15532         return (int64_t)ret_conv;
15533 }
15534
15535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15536         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15537         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15538         return ret_conv;
15539 }
15540
15541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15542         if ((_res & 1) != 0) return;
15543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15544         CHECK_ACCESS(_res_ptr);
15545         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15546         FREE((void*)_res);
15547         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15548 }
15549
15550 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15551         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15552         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15553         return (int64_t)ret_conv;
15554 }
15555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15556         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15557         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15558         return ret_conv;
15559 }
15560
15561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15562         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15563         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15564         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15565         return (int64_t)ret_conv;
15566 }
15567
15568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15569         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15570         *ret_conv = CResult_NoneErrorZ_ok();
15571         return (int64_t)ret_conv;
15572 }
15573
15574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15575         LDKIOError e_conv = LDKIOError_from_java(env, e);
15576         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15577         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15578         return (int64_t)ret_conv;
15579 }
15580
15581 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15582         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15583         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15584         return ret_conv;
15585 }
15586
15587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15588         if ((_res & 1) != 0) return;
15589         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15590         CHECK_ACCESS(_res_ptr);
15591         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15592         FREE((void*)_res);
15593         CResult_NoneErrorZ_free(_res_conv);
15594 }
15595
15596 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15597         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15598         *ret_conv = CResult_NoneErrorZ_clone(arg);
15599         return (int64_t)ret_conv;
15600 }
15601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15602         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15603         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15604         return ret_conv;
15605 }
15606
15607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15608         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15609         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15610         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15611         return (int64_t)ret_conv;
15612 }
15613
15614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15615         LDKRouteHop o_conv;
15616         o_conv.inner = (void*)(o & (~1));
15617         o_conv.is_owned = (o & 1) || (o == 0);
15618         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15619         o_conv = RouteHop_clone(&o_conv);
15620         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15621         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15622         return (int64_t)ret_conv;
15623 }
15624
15625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15626         LDKDecodeError e_conv;
15627         e_conv.inner = (void*)(e & (~1));
15628         e_conv.is_owned = (e & 1) || (e == 0);
15629         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15630         e_conv = DecodeError_clone(&e_conv);
15631         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15632         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15633         return (int64_t)ret_conv;
15634 }
15635
15636 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15637         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15638         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15639         return ret_conv;
15640 }
15641
15642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15643         if ((_res & 1) != 0) return;
15644         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15645         CHECK_ACCESS(_res_ptr);
15646         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15647         FREE((void*)_res);
15648         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15649 }
15650
15651 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15652         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15653         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15654         return (int64_t)ret_conv;
15655 }
15656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15657         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15658         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15659         return ret_conv;
15660 }
15661
15662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15663         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15664         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15665         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15666         return (int64_t)ret_conv;
15667 }
15668
15669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15670         LDKCVec_RouteHopZ _res_constr;
15671         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15672         if (_res_constr.datalen > 0)
15673                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15674         else
15675                 _res_constr.data = NULL;
15676         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15677         for (size_t k = 0; k < _res_constr.datalen; k++) {
15678                 int64_t _res_conv_10 = _res_vals[k];
15679                 LDKRouteHop _res_conv_10_conv;
15680                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15681                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15682                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15683                 _res_constr.data[k] = _res_conv_10_conv;
15684         }
15685         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15686         CVec_RouteHopZ_free(_res_constr);
15687 }
15688
15689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15690         LDKCVec_CVec_RouteHopZZ _res_constr;
15691         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15692         if (_res_constr.datalen > 0)
15693                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
15694         else
15695                 _res_constr.data = NULL;
15696         for (size_t m = 0; m < _res_constr.datalen; m++) {
15697                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
15698                 LDKCVec_RouteHopZ _res_conv_12_constr;
15699                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
15700                 if (_res_conv_12_constr.datalen > 0)
15701                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15702                 else
15703                         _res_conv_12_constr.data = NULL;
15704                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
15705                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
15706                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
15707                         LDKRouteHop _res_conv_12_conv_10_conv;
15708                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
15709                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
15710                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
15711                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
15712                 }
15713                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
15714                 _res_constr.data[m] = _res_conv_12_constr;
15715         }
15716         CVec_CVec_RouteHopZZ_free(_res_constr);
15717 }
15718
15719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15720         LDKRoute o_conv;
15721         o_conv.inner = (void*)(o & (~1));
15722         o_conv.is_owned = (o & 1) || (o == 0);
15723         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15724         o_conv = Route_clone(&o_conv);
15725         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15726         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
15727         return (int64_t)ret_conv;
15728 }
15729
15730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15731         LDKDecodeError e_conv;
15732         e_conv.inner = (void*)(e & (~1));
15733         e_conv.is_owned = (e & 1) || (e == 0);
15734         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15735         e_conv = DecodeError_clone(&e_conv);
15736         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15737         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
15738         return (int64_t)ret_conv;
15739 }
15740
15741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15742         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
15743         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
15744         return ret_conv;
15745 }
15746
15747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15748         if ((_res & 1) != 0) return;
15749         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15750         CHECK_ACCESS(_res_ptr);
15751         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
15752         FREE((void*)_res);
15753         CResult_RouteDecodeErrorZ_free(_res_conv);
15754 }
15755
15756 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
15757         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15758         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
15759         return (int64_t)ret_conv;
15760 }
15761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15762         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
15763         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
15764         return ret_conv;
15765 }
15766
15767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15768         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
15769         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15770         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
15771         return (int64_t)ret_conv;
15772 }
15773
15774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15775         LDKRouteParameters o_conv;
15776         o_conv.inner = (void*)(o & (~1));
15777         o_conv.is_owned = (o & 1) || (o == 0);
15778         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15779         o_conv = RouteParameters_clone(&o_conv);
15780         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15781         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
15782         return (int64_t)ret_conv;
15783 }
15784
15785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15786         LDKDecodeError e_conv;
15787         e_conv.inner = (void*)(e & (~1));
15788         e_conv.is_owned = (e & 1) || (e == 0);
15789         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15790         e_conv = DecodeError_clone(&e_conv);
15791         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15792         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
15793         return (int64_t)ret_conv;
15794 }
15795
15796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15797         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
15798         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
15799         return ret_conv;
15800 }
15801
15802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15803         if ((_res & 1) != 0) return;
15804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15805         CHECK_ACCESS(_res_ptr);
15806         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
15807         FREE((void*)_res);
15808         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
15809 }
15810
15811 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
15812         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15813         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
15814         return (int64_t)ret_conv;
15815 }
15816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15817         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
15818         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
15819         return ret_conv;
15820 }
15821
15822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15823         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
15824         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15825         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
15826         return (int64_t)ret_conv;
15827 }
15828
15829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15830         LDKCVec_RouteHintZ _res_constr;
15831         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15832         if (_res_constr.datalen > 0)
15833                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
15834         else
15835                 _res_constr.data = NULL;
15836         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15837         for (size_t l = 0; l < _res_constr.datalen; l++) {
15838                 int64_t _res_conv_11 = _res_vals[l];
15839                 LDKRouteHint _res_conv_11_conv;
15840                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15841                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15842                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15843                 _res_constr.data[l] = _res_conv_11_conv;
15844         }
15845         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15846         CVec_RouteHintZ_free(_res_constr);
15847 }
15848
15849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15850         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15851         *ret_copy = COption_u64Z_some(o);
15852         int64_t ret_ref = (uintptr_t)ret_copy;
15853         return ret_ref;
15854 }
15855
15856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15857         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15858         *ret_copy = COption_u64Z_none();
15859         int64_t ret_ref = (uintptr_t)ret_copy;
15860         return ret_ref;
15861 }
15862
15863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15864         if ((_res & 1) != 0) return;
15865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15866         CHECK_ACCESS(_res_ptr);
15867         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15868         FREE((void*)_res);
15869         COption_u64Z_free(_res_conv);
15870 }
15871
15872 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15873         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15874         *ret_copy = COption_u64Z_clone(arg);
15875 int64_t ret_ref = (uintptr_t)ret_copy;
15876         return ret_ref;
15877 }
15878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15879         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15880         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15881         return ret_conv;
15882 }
15883
15884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15885         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15886         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15887         *ret_copy = COption_u64Z_clone(orig_conv);
15888         int64_t ret_ref = (uintptr_t)ret_copy;
15889         return ret_ref;
15890 }
15891
15892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15893         LDKPaymentParameters o_conv;
15894         o_conv.inner = (void*)(o & (~1));
15895         o_conv.is_owned = (o & 1) || (o == 0);
15896         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15897         o_conv = PaymentParameters_clone(&o_conv);
15898         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15899         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15900         return (int64_t)ret_conv;
15901 }
15902
15903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15904         LDKDecodeError e_conv;
15905         e_conv.inner = (void*)(e & (~1));
15906         e_conv.is_owned = (e & 1) || (e == 0);
15907         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15908         e_conv = DecodeError_clone(&e_conv);
15909         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15910         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15911         return (int64_t)ret_conv;
15912 }
15913
15914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15915         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15916         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15917         return ret_conv;
15918 }
15919
15920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15921         if ((_res & 1) != 0) return;
15922         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15923         CHECK_ACCESS(_res_ptr);
15924         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15925         FREE((void*)_res);
15926         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15927 }
15928
15929 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15930         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15931         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15932         return (int64_t)ret_conv;
15933 }
15934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15935         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15936         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15937         return ret_conv;
15938 }
15939
15940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15941         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15942         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15943         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15944         return (int64_t)ret_conv;
15945 }
15946
15947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15948         LDKCVec_RouteHintHopZ _res_constr;
15949         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15950         if (_res_constr.datalen > 0)
15951                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15952         else
15953                 _res_constr.data = NULL;
15954         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15955         for (size_t o = 0; o < _res_constr.datalen; o++) {
15956                 int64_t _res_conv_14 = _res_vals[o];
15957                 LDKRouteHintHop _res_conv_14_conv;
15958                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15959                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15960                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15961                 _res_constr.data[o] = _res_conv_14_conv;
15962         }
15963         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15964         CVec_RouteHintHopZ_free(_res_constr);
15965 }
15966
15967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15968         LDKRouteHint o_conv;
15969         o_conv.inner = (void*)(o & (~1));
15970         o_conv.is_owned = (o & 1) || (o == 0);
15971         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15972         o_conv = RouteHint_clone(&o_conv);
15973         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15974         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15975         return (int64_t)ret_conv;
15976 }
15977
15978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15979         LDKDecodeError e_conv;
15980         e_conv.inner = (void*)(e & (~1));
15981         e_conv.is_owned = (e & 1) || (e == 0);
15982         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15983         e_conv = DecodeError_clone(&e_conv);
15984         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15985         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15986         return (int64_t)ret_conv;
15987 }
15988
15989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15990         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15991         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15992         return ret_conv;
15993 }
15994
15995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15996         if ((_res & 1) != 0) return;
15997         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15998         CHECK_ACCESS(_res_ptr);
15999         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
16000         FREE((void*)_res);
16001         CResult_RouteHintDecodeErrorZ_free(_res_conv);
16002 }
16003
16004 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
16005         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16006         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
16007         return (int64_t)ret_conv;
16008 }
16009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16010         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
16011         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
16012         return ret_conv;
16013 }
16014
16015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16016         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
16017         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16018         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
16019         return (int64_t)ret_conv;
16020 }
16021
16022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16023         LDKRouteHintHop o_conv;
16024         o_conv.inner = (void*)(o & (~1));
16025         o_conv.is_owned = (o & 1) || (o == 0);
16026         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16027         o_conv = RouteHintHop_clone(&o_conv);
16028         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16029         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
16030         return (int64_t)ret_conv;
16031 }
16032
16033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16034         LDKDecodeError e_conv;
16035         e_conv.inner = (void*)(e & (~1));
16036         e_conv.is_owned = (e & 1) || (e == 0);
16037         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16038         e_conv = DecodeError_clone(&e_conv);
16039         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16040         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
16041         return (int64_t)ret_conv;
16042 }
16043
16044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16045         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
16046         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
16047         return ret_conv;
16048 }
16049
16050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16051         if ((_res & 1) != 0) return;
16052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16053         CHECK_ACCESS(_res_ptr);
16054         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
16055         FREE((void*)_res);
16056         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
16057 }
16058
16059 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
16060         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16061         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
16062         return (int64_t)ret_conv;
16063 }
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16065         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
16066         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
16067         return ret_conv;
16068 }
16069
16070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16071         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
16072         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16073         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
16074         return (int64_t)ret_conv;
16075 }
16076
16077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16078         LDKCVec_ChannelDetailsZ _res_constr;
16079         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16080         if (_res_constr.datalen > 0)
16081                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16082         else
16083                 _res_constr.data = NULL;
16084         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16085         for (size_t q = 0; q < _res_constr.datalen; q++) {
16086                 int64_t _res_conv_16 = _res_vals[q];
16087                 LDKChannelDetails _res_conv_16_conv;
16088                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16089                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16090                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16091                 _res_constr.data[q] = _res_conv_16_conv;
16092         }
16093         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16094         CVec_ChannelDetailsZ_free(_res_constr);
16095 }
16096
16097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16098         LDKRoute o_conv;
16099         o_conv.inner = (void*)(o & (~1));
16100         o_conv.is_owned = (o & 1) || (o == 0);
16101         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16102         o_conv = Route_clone(&o_conv);
16103         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16104         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16105         return (int64_t)ret_conv;
16106 }
16107
16108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16109         LDKLightningError e_conv;
16110         e_conv.inner = (void*)(e & (~1));
16111         e_conv.is_owned = (e & 1) || (e == 0);
16112         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16113         e_conv = LightningError_clone(&e_conv);
16114         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16115         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16116         return (int64_t)ret_conv;
16117 }
16118
16119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16120         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
16121         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16122         return ret_conv;
16123 }
16124
16125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16126         if ((_res & 1) != 0) return;
16127         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16128         CHECK_ACCESS(_res_ptr);
16129         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16130         FREE((void*)_res);
16131         CResult_RouteLightningErrorZ_free(_res_conv);
16132 }
16133
16134 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16135         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16136         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16137         return (int64_t)ret_conv;
16138 }
16139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16140         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
16141         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16142         return ret_conv;
16143 }
16144
16145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16146         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
16147         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16148         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16149         return (int64_t)ret_conv;
16150 }
16151
16152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16153         LDKCVec_PublicKeyZ _res_constr;
16154         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16155         if (_res_constr.datalen > 0)
16156                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16157         else
16158                 _res_constr.data = NULL;
16159         for (size_t i = 0; i < _res_constr.datalen; i++) {
16160                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16161                 LDKPublicKey _res_conv_8_ref;
16162                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16163                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16164                 _res_constr.data[i] = _res_conv_8_ref;
16165         }
16166         CVec_PublicKeyZ_free(_res_constr);
16167 }
16168
16169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16170         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16171         CHECK_ACCESS(o_ptr);
16172         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16173         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
16174         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16175         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16176         return (int64_t)ret_conv;
16177 }
16178
16179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16180         LDKDecodeError e_conv;
16181         e_conv.inner = (void*)(e & (~1));
16182         e_conv.is_owned = (e & 1) || (e == 0);
16183         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16184         e_conv = DecodeError_clone(&e_conv);
16185         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16186         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16187         return (int64_t)ret_conv;
16188 }
16189
16190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16191         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
16192         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16193         return ret_conv;
16194 }
16195
16196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16197         if ((_res & 1) != 0) return;
16198         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16199         CHECK_ACCESS(_res_ptr);
16200         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16201         FREE((void*)_res);
16202         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16203 }
16204
16205 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16206         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16207         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16208         return (int64_t)ret_conv;
16209 }
16210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16211         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
16212         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16213         return ret_conv;
16214 }
16215
16216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16217         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
16218         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16219         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16220         return (int64_t)ret_conv;
16221 }
16222
16223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16224         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16225         CHECK_ACCESS(o_ptr);
16226         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16227         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
16228         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16229         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16230         int64_t ret_ref = (uintptr_t)ret_copy;
16231         return ret_ref;
16232 }
16233
16234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16235         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16236         *ret_copy = COption_ClosureReasonZ_none();
16237         int64_t ret_ref = (uintptr_t)ret_copy;
16238         return ret_ref;
16239 }
16240
16241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16242         if ((_res & 1) != 0) return;
16243         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16244         CHECK_ACCESS(_res_ptr);
16245         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16246         FREE((void*)_res);
16247         COption_ClosureReasonZ_free(_res_conv);
16248 }
16249
16250 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16251         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16252         *ret_copy = COption_ClosureReasonZ_clone(arg);
16253 int64_t ret_ref = (uintptr_t)ret_copy;
16254         return ret_ref;
16255 }
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16257         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16258         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16259         return ret_conv;
16260 }
16261
16262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16263         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16264         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16265         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16266         int64_t ret_ref = (uintptr_t)ret_copy;
16267         return ret_ref;
16268 }
16269
16270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16271         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16272         CHECK_ACCESS(o_ptr);
16273         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16274         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16275         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16276         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16277         return (int64_t)ret_conv;
16278 }
16279
16280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16281         LDKDecodeError e_conv;
16282         e_conv.inner = (void*)(e & (~1));
16283         e_conv.is_owned = (e & 1) || (e == 0);
16284         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16285         e_conv = DecodeError_clone(&e_conv);
16286         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16287         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16288         return (int64_t)ret_conv;
16289 }
16290
16291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16292         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16293         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16294         return ret_conv;
16295 }
16296
16297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16298         if ((_res & 1) != 0) return;
16299         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16300         CHECK_ACCESS(_res_ptr);
16301         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16302         FREE((void*)_res);
16303         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16304 }
16305
16306 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16307         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16308         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16309         return (int64_t)ret_conv;
16310 }
16311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16312         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16313         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16314         return ret_conv;
16315 }
16316
16317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16318         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16319         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16320         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16321         return (int64_t)ret_conv;
16322 }
16323
16324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16325         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16326         CHECK_ACCESS(o_ptr);
16327         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16328         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16329         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16330         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16331         int64_t ret_ref = (uintptr_t)ret_copy;
16332         return ret_ref;
16333 }
16334
16335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16336         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16337         *ret_copy = COption_NetworkUpdateZ_none();
16338         int64_t ret_ref = (uintptr_t)ret_copy;
16339         return ret_ref;
16340 }
16341
16342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16343         if ((_res & 1) != 0) return;
16344         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16345         CHECK_ACCESS(_res_ptr);
16346         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16347         FREE((void*)_res);
16348         COption_NetworkUpdateZ_free(_res_conv);
16349 }
16350
16351 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16352         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16353         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16354 int64_t ret_ref = (uintptr_t)ret_copy;
16355         return ret_ref;
16356 }
16357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16358         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16359         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16360         return ret_conv;
16361 }
16362
16363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16364         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16365         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16366         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16367         int64_t ret_ref = (uintptr_t)ret_copy;
16368         return ret_ref;
16369 }
16370
16371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16372         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16373         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16374         if (_res_constr.datalen > 0)
16375                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16376         else
16377                 _res_constr.data = NULL;
16378         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16379         for (size_t b = 0; b < _res_constr.datalen; b++) {
16380                 int64_t _res_conv_27 = _res_vals[b];
16381                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16382                 CHECK_ACCESS(_res_conv_27_ptr);
16383                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16384                 FREE((void*)_res_conv_27);
16385                 _res_constr.data[b] = _res_conv_27_conv;
16386         }
16387         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16388         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16389 }
16390
16391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16392         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16393         CHECK_ACCESS(o_ptr);
16394         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16395         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16396         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16397         *ret_copy = COption_EventZ_some(o_conv);
16398         int64_t ret_ref = (uintptr_t)ret_copy;
16399         return ret_ref;
16400 }
16401
16402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16403         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16404         *ret_copy = COption_EventZ_none();
16405         int64_t ret_ref = (uintptr_t)ret_copy;
16406         return ret_ref;
16407 }
16408
16409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16410         if ((_res & 1) != 0) return;
16411         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16412         CHECK_ACCESS(_res_ptr);
16413         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16414         FREE((void*)_res);
16415         COption_EventZ_free(_res_conv);
16416 }
16417
16418 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16419         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16420         *ret_copy = COption_EventZ_clone(arg);
16421 int64_t ret_ref = (uintptr_t)ret_copy;
16422         return ret_ref;
16423 }
16424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16425         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16426         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16427         return ret_conv;
16428 }
16429
16430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16431         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16432         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16433         *ret_copy = COption_EventZ_clone(orig_conv);
16434         int64_t ret_ref = (uintptr_t)ret_copy;
16435         return ret_ref;
16436 }
16437
16438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16439         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16440         CHECK_ACCESS(o_ptr);
16441         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16442         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16443         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16444         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16445         return (int64_t)ret_conv;
16446 }
16447
16448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16449         LDKDecodeError e_conv;
16450         e_conv.inner = (void*)(e & (~1));
16451         e_conv.is_owned = (e & 1) || (e == 0);
16452         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16453         e_conv = DecodeError_clone(&e_conv);
16454         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16455         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16456         return (int64_t)ret_conv;
16457 }
16458
16459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16460         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16461         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16462         return ret_conv;
16463 }
16464
16465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16466         if ((_res & 1) != 0) return;
16467         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16468         CHECK_ACCESS(_res_ptr);
16469         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16470         FREE((void*)_res);
16471         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16472 }
16473
16474 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16475         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16476         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16477         return (int64_t)ret_conv;
16478 }
16479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16480         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16481         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16482         return ret_conv;
16483 }
16484
16485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16486         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16487         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16488         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16489         return (int64_t)ret_conv;
16490 }
16491
16492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16493         LDKCVec_MessageSendEventZ _res_constr;
16494         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16495         if (_res_constr.datalen > 0)
16496                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16497         else
16498                 _res_constr.data = NULL;
16499         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16500         for (size_t s = 0; s < _res_constr.datalen; s++) {
16501                 int64_t _res_conv_18 = _res_vals[s];
16502                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16503                 CHECK_ACCESS(_res_conv_18_ptr);
16504                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16505                 FREE((void*)_res_conv_18);
16506                 _res_constr.data[s] = _res_conv_18_conv;
16507         }
16508         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16509         CVec_MessageSendEventZ_free(_res_constr);
16510 }
16511
16512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16513         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16514         CHECK_ACCESS(o_ptr);
16515         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
16516         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
16517         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16518         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
16519         return (int64_t)ret_conv;
16520 }
16521
16522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16523         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
16524         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16525         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
16526         return (int64_t)ret_conv;
16527 }
16528
16529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16530         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
16531         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
16532         return ret_conv;
16533 }
16534
16535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16536         if ((_res & 1) != 0) return;
16537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16538         CHECK_ACCESS(_res_ptr);
16539         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
16540         FREE((void*)_res);
16541         CResult_TxOutAccessErrorZ_free(_res_conv);
16542 }
16543
16544 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
16545         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16546         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
16547         return (int64_t)ret_conv;
16548 }
16549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16550         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
16551         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
16552         return ret_conv;
16553 }
16554
16555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16556         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
16557         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16558         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
16559         return (int64_t)ret_conv;
16560 }
16561
16562 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
16563         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16564         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
16565         return ((int64_t)ret_conv);
16566 }
16567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16568         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
16569         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
16570         return ret_conv;
16571 }
16572
16573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16574         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
16575         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16576         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
16577         return ((int64_t)ret_conv);
16578 }
16579
16580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
16581         LDKTransaction b_ref;
16582         b_ref.datalen = (*env)->GetArrayLength(env, b);
16583         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
16584         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
16585         b_ref.data_is_owned = true;
16586         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16587         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
16588         return ((int64_t)ret_conv);
16589 }
16590
16591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16592         if ((_res & 1) != 0) return;
16593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16594         CHECK_ACCESS(_res_ptr);
16595         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
16596         FREE((void*)_res);
16597         C2Tuple_usizeTransactionZ_free(_res_conv);
16598 }
16599
16600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16601         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
16602         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16603         if (_res_constr.datalen > 0)
16604                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16605         else
16606                 _res_constr.data = NULL;
16607         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16608         for (size_t c = 0; c < _res_constr.datalen; c++) {
16609                 int64_t _res_conv_28 = _res_vals[c];
16610                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
16611                 CHECK_ACCESS(_res_conv_28_ptr);
16612                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
16613                 FREE((void*)_res_conv_28);
16614                 _res_constr.data[c] = _res_conv_28_conv;
16615         }
16616         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16617         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
16618 }
16619
16620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16621         LDKCVec_TxidZ _res_constr;
16622         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16623         if (_res_constr.datalen > 0)
16624                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
16625         else
16626                 _res_constr.data = NULL;
16627         for (size_t i = 0; i < _res_constr.datalen; i++) {
16628                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16629                 LDKThirtyTwoBytes _res_conv_8_ref;
16630                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16631                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16632                 _res_constr.data[i] = _res_conv_8_ref;
16633         }
16634         CVec_TxidZ_free(_res_constr);
16635 }
16636
16637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
16638         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16639         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
16640         return (int64_t)ret_conv;
16641 }
16642
16643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
16644         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
16645         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16646         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
16647         return (int64_t)ret_conv;
16648 }
16649
16650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16651         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
16652         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
16653         return ret_conv;
16654 }
16655
16656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16657         if ((_res & 1) != 0) return;
16658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16659         CHECK_ACCESS(_res_ptr);
16660         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
16661         FREE((void*)_res);
16662         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
16663 }
16664
16665 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
16666         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16667         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
16668         return (int64_t)ret_conv;
16669 }
16670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16671         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
16672         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
16673         return ret_conv;
16674 }
16675
16676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16677         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
16678         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16679         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
16680         return (int64_t)ret_conv;
16681 }
16682
16683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16684         LDKCVec_MonitorEventZ _res_constr;
16685         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16686         if (_res_constr.datalen > 0)
16687                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
16688         else
16689                 _res_constr.data = NULL;
16690         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16691         for (size_t o = 0; o < _res_constr.datalen; o++) {
16692                 int64_t _res_conv_14 = _res_vals[o];
16693                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
16694                 CHECK_ACCESS(_res_conv_14_ptr);
16695                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
16696                 FREE((void*)_res_conv_14);
16697                 _res_constr.data[o] = _res_conv_14_conv;
16698         }
16699         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16700         CVec_MonitorEventZ_free(_res_constr);
16701 }
16702
16703 static inline uintptr_t C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR arg) {
16704         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16705         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(arg);
16706         return ((int64_t)ret_conv);
16707 }
16708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16709         LDKC2Tuple_OutPointCVec_MonitorEventZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(arg & ~1);
16710         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(arg_conv);
16711         return ret_conv;
16712 }
16713
16714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16715         LDKC2Tuple_OutPointCVec_MonitorEventZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(orig & ~1);
16716         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16717         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(orig_conv);
16718         return ((int64_t)ret_conv);
16719 }
16720
16721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
16722         LDKOutPoint a_conv;
16723         a_conv.inner = (void*)(a & (~1));
16724         a_conv.is_owned = (a & 1) || (a == 0);
16725         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16726         a_conv = OutPoint_clone(&a_conv);
16727         LDKCVec_MonitorEventZ b_constr;
16728         b_constr.datalen = (*env)->GetArrayLength(env, b);
16729         if (b_constr.datalen > 0)
16730                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
16731         else
16732                 b_constr.data = NULL;
16733         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16734         for (size_t o = 0; o < b_constr.datalen; o++) {
16735                 int64_t b_conv_14 = b_vals[o];
16736                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
16737                 CHECK_ACCESS(b_conv_14_ptr);
16738                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
16739                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
16740                 b_constr.data[o] = b_conv_14_conv;
16741         }
16742         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16743         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16744         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_new(a_conv, b_constr);
16745         return ((int64_t)ret_conv);
16746 }
16747
16748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16749         if ((_res & 1) != 0) return;
16750         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16751         CHECK_ACCESS(_res_ptr);
16752         LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_ptr);
16753         FREE((void*)_res);
16754         C2Tuple_OutPointCVec_MonitorEventZZ_free(_res_conv);
16755 }
16756
16757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorEventZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16758         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ _res_constr;
16759         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16760         if (_res_constr.datalen > 0)
16761                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
16762         else
16763                 _res_constr.data = NULL;
16764         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16765         for (size_t m = 0; m < _res_constr.datalen; m++) {
16766                 int64_t _res_conv_38 = _res_vals[m];
16767                 void* _res_conv_38_ptr = (void*)(((uintptr_t)_res_conv_38) & ~1);
16768                 CHECK_ACCESS(_res_conv_38_ptr);
16769                 LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_conv_38_ptr);
16770                 FREE((void*)_res_conv_38);
16771                 _res_constr.data[m] = _res_conv_38_conv;
16772         }
16773         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16774         CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(_res_constr);
16775 }
16776
16777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16778         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16779         CHECK_ACCESS(o_ptr);
16780         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
16781         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
16782         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16783         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
16784         int64_t ret_ref = (uintptr_t)ret_copy;
16785         return ret_ref;
16786 }
16787
16788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
16789         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16790         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
16791         int64_t ret_ref = (uintptr_t)ret_copy;
16792         return ret_ref;
16793 }
16794
16795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16796         if ((_res & 1) != 0) return;
16797         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16798         CHECK_ACCESS(_res_ptr);
16799         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
16800         FREE((void*)_res);
16801         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
16802 }
16803
16804 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
16805         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16806         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
16807 int64_t ret_ref = (uintptr_t)ret_copy;
16808         return ret_ref;
16809 }
16810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16811         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
16812         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
16813         return ret_conv;
16814 }
16815
16816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16817         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
16818         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16819         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
16820         int64_t ret_ref = (uintptr_t)ret_copy;
16821         return ret_ref;
16822 }
16823
16824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16825         LDKFixedPenaltyScorer o_conv;
16826         o_conv.inner = (void*)(o & (~1));
16827         o_conv.is_owned = (o & 1) || (o == 0);
16828         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16829         o_conv = FixedPenaltyScorer_clone(&o_conv);
16830         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16831         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
16832         return (int64_t)ret_conv;
16833 }
16834
16835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16836         LDKDecodeError e_conv;
16837         e_conv.inner = (void*)(e & (~1));
16838         e_conv.is_owned = (e & 1) || (e == 0);
16839         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16840         e_conv = DecodeError_clone(&e_conv);
16841         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16842         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16843         return (int64_t)ret_conv;
16844 }
16845
16846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16847         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
16848         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16849         return ret_conv;
16850 }
16851
16852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16853         if ((_res & 1) != 0) return;
16854         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16855         CHECK_ACCESS(_res_ptr);
16856         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16857         FREE((void*)_res);
16858         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16859 }
16860
16861 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16862         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16863         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16864         return (int64_t)ret_conv;
16865 }
16866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16867         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
16868         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16869         return ret_conv;
16870 }
16871
16872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16873         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
16874         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16875         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16876         return (int64_t)ret_conv;
16877 }
16878
16879 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
16880         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16881         *ret_conv = C2Tuple_u64u64Z_clone(arg);
16882         return ((int64_t)ret_conv);
16883 }
16884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16885         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
16886         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
16887         return ret_conv;
16888 }
16889
16890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16891         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
16892         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16893         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
16894         return ((int64_t)ret_conv);
16895 }
16896
16897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16898         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16899         *ret_conv = C2Tuple_u64u64Z_new(a, b);
16900         return ((int64_t)ret_conv);
16901 }
16902
16903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16904         if ((_res & 1) != 0) return;
16905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16906         CHECK_ACCESS(_res_ptr);
16907         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
16908         FREE((void*)_res);
16909         C2Tuple_u64u64Z_free(_res_conv);
16910 }
16911
16912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16913         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16914         CHECK_ACCESS(o_ptr);
16915         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
16916         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
16917         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16918         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
16919         int64_t ret_ref = (uintptr_t)ret_copy;
16920         return ret_ref;
16921 }
16922
16923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
16924         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16925         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
16926         int64_t ret_ref = (uintptr_t)ret_copy;
16927         return ret_ref;
16928 }
16929
16930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16931         if ((_res & 1) != 0) return;
16932         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16933         CHECK_ACCESS(_res_ptr);
16934         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
16935         FREE((void*)_res);
16936         COption_C2Tuple_u64u64ZZ_free(_res_conv);
16937 }
16938
16939 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
16940         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16941         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
16942 int64_t ret_ref = (uintptr_t)ret_copy;
16943         return ret_ref;
16944 }
16945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16946         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
16947         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
16948         return ret_conv;
16949 }
16950
16951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16952         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
16953         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16954         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
16955         int64_t ret_ref = (uintptr_t)ret_copy;
16956         return ret_ref;
16957 }
16958
16959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16960         LDKCVec_NodeIdZ _res_constr;
16961         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16962         if (_res_constr.datalen > 0)
16963                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
16964         else
16965                 _res_constr.data = NULL;
16966         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16967         for (size_t i = 0; i < _res_constr.datalen; i++) {
16968                 int64_t _res_conv_8 = _res_vals[i];
16969                 LDKNodeId _res_conv_8_conv;
16970                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
16971                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
16972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
16973                 _res_constr.data[i] = _res_conv_8_conv;
16974         }
16975         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16976         CVec_NodeIdZ_free(_res_constr);
16977 }
16978
16979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16980         LDKProbabilisticScorer o_conv;
16981         o_conv.inner = (void*)(o & (~1));
16982         o_conv.is_owned = (o & 1) || (o == 0);
16983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16984         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16985         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16986         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16987         return (int64_t)ret_conv;
16988 }
16989
16990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16991         LDKDecodeError e_conv;
16992         e_conv.inner = (void*)(e & (~1));
16993         e_conv.is_owned = (e & 1) || (e == 0);
16994         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16995         e_conv = DecodeError_clone(&e_conv);
16996         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16997         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16998         return (int64_t)ret_conv;
16999 }
17000
17001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17002         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
17003         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
17004         return ret_conv;
17005 }
17006
17007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17008         if ((_res & 1) != 0) return;
17009         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17010         CHECK_ACCESS(_res_ptr);
17011         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
17012         FREE((void*)_res);
17013         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
17014 }
17015
17016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17017         LDKInitFeatures o_conv;
17018         o_conv.inner = (void*)(o & (~1));
17019         o_conv.is_owned = (o & 1) || (o == 0);
17020         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17021         o_conv = InitFeatures_clone(&o_conv);
17022         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17023         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
17024         return (int64_t)ret_conv;
17025 }
17026
17027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17028         LDKDecodeError e_conv;
17029         e_conv.inner = (void*)(e & (~1));
17030         e_conv.is_owned = (e & 1) || (e == 0);
17031         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17032         e_conv = DecodeError_clone(&e_conv);
17033         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17034         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
17035         return (int64_t)ret_conv;
17036 }
17037
17038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17039         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
17040         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
17041         return ret_conv;
17042 }
17043
17044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17045         if ((_res & 1) != 0) return;
17046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17047         CHECK_ACCESS(_res_ptr);
17048         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
17049         FREE((void*)_res);
17050         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
17051 }
17052
17053 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17054         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17055         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
17056         return (int64_t)ret_conv;
17057 }
17058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17059         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
17060         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17061         return ret_conv;
17062 }
17063
17064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17065         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
17066         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17067         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
17068         return (int64_t)ret_conv;
17069 }
17070
17071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17072         LDKChannelFeatures o_conv;
17073         o_conv.inner = (void*)(o & (~1));
17074         o_conv.is_owned = (o & 1) || (o == 0);
17075         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17076         o_conv = ChannelFeatures_clone(&o_conv);
17077         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17078         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
17079         return (int64_t)ret_conv;
17080 }
17081
17082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17083         LDKDecodeError e_conv;
17084         e_conv.inner = (void*)(e & (~1));
17085         e_conv.is_owned = (e & 1) || (e == 0);
17086         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17087         e_conv = DecodeError_clone(&e_conv);
17088         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17089         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
17090         return (int64_t)ret_conv;
17091 }
17092
17093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17094         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
17095         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
17096         return ret_conv;
17097 }
17098
17099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17100         if ((_res & 1) != 0) return;
17101         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17102         CHECK_ACCESS(_res_ptr);
17103         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
17104         FREE((void*)_res);
17105         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
17106 }
17107
17108 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17109         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17110         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
17111         return (int64_t)ret_conv;
17112 }
17113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17114         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
17115         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17116         return ret_conv;
17117 }
17118
17119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17120         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
17121         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17122         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
17123         return (int64_t)ret_conv;
17124 }
17125
17126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17127         LDKNodeFeatures o_conv;
17128         o_conv.inner = (void*)(o & (~1));
17129         o_conv.is_owned = (o & 1) || (o == 0);
17130         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17131         o_conv = NodeFeatures_clone(&o_conv);
17132         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17133         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
17134         return (int64_t)ret_conv;
17135 }
17136
17137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17138         LDKDecodeError e_conv;
17139         e_conv.inner = (void*)(e & (~1));
17140         e_conv.is_owned = (e & 1) || (e == 0);
17141         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17142         e_conv = DecodeError_clone(&e_conv);
17143         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17144         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
17145         return (int64_t)ret_conv;
17146 }
17147
17148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17149         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
17150         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
17151         return ret_conv;
17152 }
17153
17154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17155         if ((_res & 1) != 0) return;
17156         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17157         CHECK_ACCESS(_res_ptr);
17158         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
17159         FREE((void*)_res);
17160         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
17161 }
17162
17163 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17164         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17165         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
17166         return (int64_t)ret_conv;
17167 }
17168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17169         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
17170         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17171         return ret_conv;
17172 }
17173
17174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17175         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
17176         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17177         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
17178         return (int64_t)ret_conv;
17179 }
17180
17181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17182         LDKInvoiceFeatures o_conv;
17183         o_conv.inner = (void*)(o & (~1));
17184         o_conv.is_owned = (o & 1) || (o == 0);
17185         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17186         o_conv = InvoiceFeatures_clone(&o_conv);
17187         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17188         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
17189         return (int64_t)ret_conv;
17190 }
17191
17192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17193         LDKDecodeError e_conv;
17194         e_conv.inner = (void*)(e & (~1));
17195         e_conv.is_owned = (e & 1) || (e == 0);
17196         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17197         e_conv = DecodeError_clone(&e_conv);
17198         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17199         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
17200         return (int64_t)ret_conv;
17201 }
17202
17203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17204         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
17205         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17206         return ret_conv;
17207 }
17208
17209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17210         if ((_res & 1) != 0) return;
17211         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17212         CHECK_ACCESS(_res_ptr);
17213         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17214         FREE((void*)_res);
17215         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17216 }
17217
17218 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17219         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17220         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17221         return (int64_t)ret_conv;
17222 }
17223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17224         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
17225         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17226         return ret_conv;
17227 }
17228
17229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17230         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
17231         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17232         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
17233         return (int64_t)ret_conv;
17234 }
17235
17236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17237         LDKChannelTypeFeatures o_conv;
17238         o_conv.inner = (void*)(o & (~1));
17239         o_conv.is_owned = (o & 1) || (o == 0);
17240         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17241         o_conv = ChannelTypeFeatures_clone(&o_conv);
17242         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17243         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
17244         return (int64_t)ret_conv;
17245 }
17246
17247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17248         LDKDecodeError e_conv;
17249         e_conv.inner = (void*)(e & (~1));
17250         e_conv.is_owned = (e & 1) || (e == 0);
17251         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17252         e_conv = DecodeError_clone(&e_conv);
17253         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17254         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
17255         return (int64_t)ret_conv;
17256 }
17257
17258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17259         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
17260         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
17261         return ret_conv;
17262 }
17263
17264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17265         if ((_res & 1) != 0) return;
17266         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17267         CHECK_ACCESS(_res_ptr);
17268         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
17269         FREE((void*)_res);
17270         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
17271 }
17272
17273 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17274         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17275         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
17276         return (int64_t)ret_conv;
17277 }
17278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17279         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
17280         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17281         return ret_conv;
17282 }
17283
17284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17285         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
17286         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17287         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
17288         return (int64_t)ret_conv;
17289 }
17290
17291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17292         LDKNodeId o_conv;
17293         o_conv.inner = (void*)(o & (~1));
17294         o_conv.is_owned = (o & 1) || (o == 0);
17295         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17296         o_conv = NodeId_clone(&o_conv);
17297         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17298         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17299         return (int64_t)ret_conv;
17300 }
17301
17302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17303         LDKDecodeError e_conv;
17304         e_conv.inner = (void*)(e & (~1));
17305         e_conv.is_owned = (e & 1) || (e == 0);
17306         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17307         e_conv = DecodeError_clone(&e_conv);
17308         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17309         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17310         return (int64_t)ret_conv;
17311 }
17312
17313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17314         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17315         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17316         return ret_conv;
17317 }
17318
17319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17320         if ((_res & 1) != 0) return;
17321         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17322         CHECK_ACCESS(_res_ptr);
17323         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17324         FREE((void*)_res);
17325         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17326 }
17327
17328 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17329         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17330         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17331         return (int64_t)ret_conv;
17332 }
17333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17334         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17335         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17336         return ret_conv;
17337 }
17338
17339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17340         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17341         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17342         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17343         return (int64_t)ret_conv;
17344 }
17345
17346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17347         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17348         CHECK_ACCESS(o_ptr);
17349         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17350         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
17351         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17352         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17353         return (int64_t)ret_conv;
17354 }
17355
17356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17357         LDKDecodeError e_conv;
17358         e_conv.inner = (void*)(e & (~1));
17359         e_conv.is_owned = (e & 1) || (e == 0);
17360         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17361         e_conv = DecodeError_clone(&e_conv);
17362         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17363         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17364         return (int64_t)ret_conv;
17365 }
17366
17367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17368         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17369         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17370         return ret_conv;
17371 }
17372
17373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17374         if ((_res & 1) != 0) return;
17375         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17376         CHECK_ACCESS(_res_ptr);
17377         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17378         FREE((void*)_res);
17379         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17380 }
17381
17382 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17383         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17384         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17385         return (int64_t)ret_conv;
17386 }
17387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17388         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17389         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17390         return ret_conv;
17391 }
17392
17393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17394         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17395         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17396         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17397         return (int64_t)ret_conv;
17398 }
17399
17400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17401         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17402         CHECK_ACCESS(o_ptr);
17403         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17404         if (o_conv.free == LDKAccess_JCalls_free) {
17405                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17406                 LDKAccess_JCalls_cloned(&o_conv);
17407         }
17408         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17409         *ret_copy = COption_AccessZ_some(o_conv);
17410         int64_t ret_ref = (uintptr_t)ret_copy;
17411         return ret_ref;
17412 }
17413
17414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17415         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17416         *ret_copy = COption_AccessZ_none();
17417         int64_t ret_ref = (uintptr_t)ret_copy;
17418         return ret_ref;
17419 }
17420
17421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17422         if ((_res & 1) != 0) return;
17423         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17424         CHECK_ACCESS(_res_ptr);
17425         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17426         FREE((void*)_res);
17427         COption_AccessZ_free(_res_conv);
17428 }
17429
17430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17431         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17432         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17433         return (int64_t)ret_conv;
17434 }
17435
17436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17437         LDKLightningError e_conv;
17438         e_conv.inner = (void*)(e & (~1));
17439         e_conv.is_owned = (e & 1) || (e == 0);
17440         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17441         e_conv = LightningError_clone(&e_conv);
17442         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17443         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17444         return (int64_t)ret_conv;
17445 }
17446
17447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17448         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17449         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
17450         return ret_conv;
17451 }
17452
17453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17454         if ((_res & 1) != 0) return;
17455         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17456         CHECK_ACCESS(_res_ptr);
17457         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17458         FREE((void*)_res);
17459         CResult_boolLightningErrorZ_free(_res_conv);
17460 }
17461
17462 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17463         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17464         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17465         return (int64_t)ret_conv;
17466 }
17467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17468         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17469         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17470         return ret_conv;
17471 }
17472
17473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17474         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17475         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17476         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17477         return (int64_t)ret_conv;
17478 }
17479
17480 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17481         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17482         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17483         return ((int64_t)ret_conv);
17484 }
17485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17486         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17487         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17488         return ret_conv;
17489 }
17490
17491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17492         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17493         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17494         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17495         return ((int64_t)ret_conv);
17496 }
17497
17498 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) {
17499         LDKChannelAnnouncement a_conv;
17500         a_conv.inner = (void*)(a & (~1));
17501         a_conv.is_owned = (a & 1) || (a == 0);
17502         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17503         a_conv = ChannelAnnouncement_clone(&a_conv);
17504         LDKChannelUpdate b_conv;
17505         b_conv.inner = (void*)(b & (~1));
17506         b_conv.is_owned = (b & 1) || (b == 0);
17507         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17508         b_conv = ChannelUpdate_clone(&b_conv);
17509         LDKChannelUpdate c_conv;
17510         c_conv.inner = (void*)(c & (~1));
17511         c_conv.is_owned = (c & 1) || (c == 0);
17512         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17513         c_conv = ChannelUpdate_clone(&c_conv);
17514         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17515         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17516         return ((int64_t)ret_conv);
17517 }
17518
17519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17520         if ((_res & 1) != 0) return;
17521         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17522         CHECK_ACCESS(_res_ptr);
17523         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17524         FREE((void*)_res);
17525         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17526 }
17527
17528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17529         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17530         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17531         if (_res_constr.datalen > 0)
17532                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17533         else
17534                 _res_constr.data = NULL;
17535         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17536         for (size_t h = 0; h < _res_constr.datalen; h++) {
17537                 int64_t _res_conv_59 = _res_vals[h];
17538                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
17539                 CHECK_ACCESS(_res_conv_59_ptr);
17540                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17541                 FREE((void*)_res_conv_59);
17542                 _res_constr.data[h] = _res_conv_59_conv;
17543         }
17544         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17545         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
17546 }
17547
17548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17549         LDKCVec_NodeAnnouncementZ _res_constr;
17550         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17551         if (_res_constr.datalen > 0)
17552                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
17553         else
17554                 _res_constr.data = NULL;
17555         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17556         for (size_t s = 0; s < _res_constr.datalen; s++) {
17557                 int64_t _res_conv_18 = _res_vals[s];
17558                 LDKNodeAnnouncement _res_conv_18_conv;
17559                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
17560                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
17561                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
17562                 _res_constr.data[s] = _res_conv_18_conv;
17563         }
17564         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17565         CVec_NodeAnnouncementZ_free(_res_constr);
17566 }
17567
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
17569         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17570         *ret_conv = CResult_NoneLightningErrorZ_ok();
17571         return (int64_t)ret_conv;
17572 }
17573
17574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17575         LDKLightningError e_conv;
17576         e_conv.inner = (void*)(e & (~1));
17577         e_conv.is_owned = (e & 1) || (e == 0);
17578         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17579         e_conv = LightningError_clone(&e_conv);
17580         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17581         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
17582         return (int64_t)ret_conv;
17583 }
17584
17585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17586         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
17587         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
17588         return ret_conv;
17589 }
17590
17591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17592         if ((_res & 1) != 0) return;
17593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17594         CHECK_ACCESS(_res_ptr);
17595         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
17596         FREE((void*)_res);
17597         CResult_NoneLightningErrorZ_free(_res_conv);
17598 }
17599
17600 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
17601         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17602         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
17603         return (int64_t)ret_conv;
17604 }
17605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17606         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
17607         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
17608         return ret_conv;
17609 }
17610
17611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17612         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
17613         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17614         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
17615         return (int64_t)ret_conv;
17616 }
17617
17618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17619         LDKChannelUpdateInfo o_conv;
17620         o_conv.inner = (void*)(o & (~1));
17621         o_conv.is_owned = (o & 1) || (o == 0);
17622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17623         o_conv = ChannelUpdateInfo_clone(&o_conv);
17624         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17625         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
17626         return (int64_t)ret_conv;
17627 }
17628
17629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17630         LDKDecodeError e_conv;
17631         e_conv.inner = (void*)(e & (~1));
17632         e_conv.is_owned = (e & 1) || (e == 0);
17633         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17634         e_conv = DecodeError_clone(&e_conv);
17635         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17636         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
17637         return (int64_t)ret_conv;
17638 }
17639
17640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17641         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
17642         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
17643         return ret_conv;
17644 }
17645
17646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17647         if ((_res & 1) != 0) return;
17648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17649         CHECK_ACCESS(_res_ptr);
17650         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
17651         FREE((void*)_res);
17652         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
17653 }
17654
17655 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
17656         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17657         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
17658         return (int64_t)ret_conv;
17659 }
17660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17661         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
17662         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
17663         return ret_conv;
17664 }
17665
17666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17667         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
17668         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17669         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
17670         return (int64_t)ret_conv;
17671 }
17672
17673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17674         LDKChannelInfo o_conv;
17675         o_conv.inner = (void*)(o & (~1));
17676         o_conv.is_owned = (o & 1) || (o == 0);
17677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17678         o_conv = ChannelInfo_clone(&o_conv);
17679         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17680         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
17681         return (int64_t)ret_conv;
17682 }
17683
17684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17685         LDKDecodeError e_conv;
17686         e_conv.inner = (void*)(e & (~1));
17687         e_conv.is_owned = (e & 1) || (e == 0);
17688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17689         e_conv = DecodeError_clone(&e_conv);
17690         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17691         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
17692         return (int64_t)ret_conv;
17693 }
17694
17695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17696         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
17697         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
17698         return ret_conv;
17699 }
17700
17701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17702         if ((_res & 1) != 0) return;
17703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17704         CHECK_ACCESS(_res_ptr);
17705         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
17706         FREE((void*)_res);
17707         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
17708 }
17709
17710 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17711         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17712         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
17713         return (int64_t)ret_conv;
17714 }
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17716         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
17717         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17718         return ret_conv;
17719 }
17720
17721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17722         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17723         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17724         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17725         return (int64_t)ret_conv;
17726 }
17727
17728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17729         LDKRoutingFees o_conv;
17730         o_conv.inner = (void*)(o & (~1));
17731         o_conv.is_owned = (o & 1) || (o == 0);
17732         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17733         o_conv = RoutingFees_clone(&o_conv);
17734         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17735         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17736         return (int64_t)ret_conv;
17737 }
17738
17739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17740         LDKDecodeError e_conv;
17741         e_conv.inner = (void*)(e & (~1));
17742         e_conv.is_owned = (e & 1) || (e == 0);
17743         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17744         e_conv = DecodeError_clone(&e_conv);
17745         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17746         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17747         return (int64_t)ret_conv;
17748 }
17749
17750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17751         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17752         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17753         return ret_conv;
17754 }
17755
17756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17757         if ((_res & 1) != 0) return;
17758         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17759         CHECK_ACCESS(_res_ptr);
17760         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17761         FREE((void*)_res);
17762         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17763 }
17764
17765 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17766         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17767         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17768         return (int64_t)ret_conv;
17769 }
17770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17771         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17772         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17773         return ret_conv;
17774 }
17775
17776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17777         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17778         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17779         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17780         return (int64_t)ret_conv;
17781 }
17782
17783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17784         LDKCVec_NetAddressZ _res_constr;
17785         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17786         if (_res_constr.datalen > 0)
17787                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17788         else
17789                 _res_constr.data = NULL;
17790         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17791         for (size_t m = 0; m < _res_constr.datalen; m++) {
17792                 int64_t _res_conv_12 = _res_vals[m];
17793                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17794                 CHECK_ACCESS(_res_conv_12_ptr);
17795                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17796                 FREE((void*)_res_conv_12);
17797                 _res_constr.data[m] = _res_conv_12_conv;
17798         }
17799         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17800         CVec_NetAddressZ_free(_res_constr);
17801 }
17802
17803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17804         LDKNodeAnnouncementInfo o_conv;
17805         o_conv.inner = (void*)(o & (~1));
17806         o_conv.is_owned = (o & 1) || (o == 0);
17807         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17808         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17809         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17810         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17811         return (int64_t)ret_conv;
17812 }
17813
17814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17815         LDKDecodeError e_conv;
17816         e_conv.inner = (void*)(e & (~1));
17817         e_conv.is_owned = (e & 1) || (e == 0);
17818         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17819         e_conv = DecodeError_clone(&e_conv);
17820         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17821         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17822         return (int64_t)ret_conv;
17823 }
17824
17825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17826         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17827         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17828         return ret_conv;
17829 }
17830
17831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17832         if ((_res & 1) != 0) return;
17833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17834         CHECK_ACCESS(_res_ptr);
17835         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17836         FREE((void*)_res);
17837         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17838 }
17839
17840 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17841         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17842         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17843         return (int64_t)ret_conv;
17844 }
17845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17846         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17847         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17848         return ret_conv;
17849 }
17850
17851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17852         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17853         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17854         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17855         return (int64_t)ret_conv;
17856 }
17857
17858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17859         LDKNodeAlias o_conv;
17860         o_conv.inner = (void*)(o & (~1));
17861         o_conv.is_owned = (o & 1) || (o == 0);
17862         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17863         o_conv = NodeAlias_clone(&o_conv);
17864         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17865         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
17866         return (int64_t)ret_conv;
17867 }
17868
17869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17870         LDKDecodeError e_conv;
17871         e_conv.inner = (void*)(e & (~1));
17872         e_conv.is_owned = (e & 1) || (e == 0);
17873         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17874         e_conv = DecodeError_clone(&e_conv);
17875         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17876         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
17877         return (int64_t)ret_conv;
17878 }
17879
17880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17881         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
17882         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
17883         return ret_conv;
17884 }
17885
17886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17887         if ((_res & 1) != 0) return;
17888         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17889         CHECK_ACCESS(_res_ptr);
17890         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
17891         FREE((void*)_res);
17892         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
17893 }
17894
17895 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
17896         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17897         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
17898         return (int64_t)ret_conv;
17899 }
17900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17901         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
17902         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
17903         return ret_conv;
17904 }
17905
17906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17907         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
17908         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17909         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
17910         return (int64_t)ret_conv;
17911 }
17912
17913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17914         LDKCVec_u64Z _res_constr;
17915         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17916         if (_res_constr.datalen > 0)
17917                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17918         else
17919                 _res_constr.data = NULL;
17920         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17921         for (size_t g = 0; g < _res_constr.datalen; g++) {
17922                 int64_t _res_conv_6 = _res_vals[g];
17923                 _res_constr.data[g] = _res_conv_6;
17924         }
17925         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17926         CVec_u64Z_free(_res_constr);
17927 }
17928
17929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17930         LDKNodeInfo o_conv;
17931         o_conv.inner = (void*)(o & (~1));
17932         o_conv.is_owned = (o & 1) || (o == 0);
17933         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17934         o_conv = NodeInfo_clone(&o_conv);
17935         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17936         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17937         return (int64_t)ret_conv;
17938 }
17939
17940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17941         LDKDecodeError e_conv;
17942         e_conv.inner = (void*)(e & (~1));
17943         e_conv.is_owned = (e & 1) || (e == 0);
17944         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17945         e_conv = DecodeError_clone(&e_conv);
17946         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17947         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17948         return (int64_t)ret_conv;
17949 }
17950
17951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17952         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17953         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17954         return ret_conv;
17955 }
17956
17957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17958         if ((_res & 1) != 0) return;
17959         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17960         CHECK_ACCESS(_res_ptr);
17961         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17962         FREE((void*)_res);
17963         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17964 }
17965
17966 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17967         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17968         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17969         return (int64_t)ret_conv;
17970 }
17971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17972         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17973         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17974         return ret_conv;
17975 }
17976
17977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17978         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17979         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17980         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17981         return (int64_t)ret_conv;
17982 }
17983
17984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17985         LDKNetworkGraph o_conv;
17986         o_conv.inner = (void*)(o & (~1));
17987         o_conv.is_owned = (o & 1) || (o == 0);
17988         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17989         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
17990         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17991         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17992         return (int64_t)ret_conv;
17993 }
17994
17995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17996         LDKDecodeError e_conv;
17997         e_conv.inner = (void*)(e & (~1));
17998         e_conv.is_owned = (e & 1) || (e == 0);
17999         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18000         e_conv = DecodeError_clone(&e_conv);
18001         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18002         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18003         return (int64_t)ret_conv;
18004 }
18005
18006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18007         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
18008         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18009         return ret_conv;
18010 }
18011
18012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18013         if ((_res & 1) != 0) return;
18014         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18015         CHECK_ACCESS(_res_ptr);
18016         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
18017         FREE((void*)_res);
18018         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
18019 }
18020
18021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
18022         LDKCVec_NetAddressZ o_constr;
18023         o_constr.datalen = (*env)->GetArrayLength(env, o);
18024         if (o_constr.datalen > 0)
18025                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18026         else
18027                 o_constr.data = NULL;
18028         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18029         for (size_t m = 0; m < o_constr.datalen; m++) {
18030                 int64_t o_conv_12 = o_vals[m];
18031                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
18032                 CHECK_ACCESS(o_conv_12_ptr);
18033                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
18034                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
18035                 o_constr.data[m] = o_conv_12_conv;
18036         }
18037         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18038         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18039         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
18040         int64_t ret_ref = (uintptr_t)ret_copy;
18041         return ret_ref;
18042 }
18043
18044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
18045         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18046         *ret_copy = COption_CVec_NetAddressZZ_none();
18047         int64_t ret_ref = (uintptr_t)ret_copy;
18048         return ret_ref;
18049 }
18050
18051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18052         if ((_res & 1) != 0) return;
18053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18054         CHECK_ACCESS(_res_ptr);
18055         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
18056         FREE((void*)_res);
18057         COption_CVec_NetAddressZZ_free(_res_conv);
18058 }
18059
18060 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
18061         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18062         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
18063 int64_t ret_ref = (uintptr_t)ret_copy;
18064         return ret_ref;
18065 }
18066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18067         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
18068         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
18069         return ret_conv;
18070 }
18071
18072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18073         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
18074         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18075         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
18076         int64_t ret_ref = (uintptr_t)ret_copy;
18077         return ret_ref;
18078 }
18079
18080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18081         LDKDelayedPaymentOutputDescriptor o_conv;
18082         o_conv.inner = (void*)(o & (~1));
18083         o_conv.is_owned = (o & 1) || (o == 0);
18084         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18085         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
18086         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18087         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18088         return (int64_t)ret_conv;
18089 }
18090
18091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18092         LDKDecodeError e_conv;
18093         e_conv.inner = (void*)(e & (~1));
18094         e_conv.is_owned = (e & 1) || (e == 0);
18095         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18096         e_conv = DecodeError_clone(&e_conv);
18097         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18098         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18099         return (int64_t)ret_conv;
18100 }
18101
18102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18103         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18104         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18105         return ret_conv;
18106 }
18107
18108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18109         if ((_res & 1) != 0) return;
18110         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18111         CHECK_ACCESS(_res_ptr);
18112         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18113         FREE((void*)_res);
18114         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18115 }
18116
18117 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18118         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18119         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18120         return (int64_t)ret_conv;
18121 }
18122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18123         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18124         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18125         return ret_conv;
18126 }
18127
18128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18129         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18130         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18131         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18132         return (int64_t)ret_conv;
18133 }
18134
18135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18136         LDKStaticPaymentOutputDescriptor o_conv;
18137         o_conv.inner = (void*)(o & (~1));
18138         o_conv.is_owned = (o & 1) || (o == 0);
18139         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18140         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
18141         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18142         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18143         return (int64_t)ret_conv;
18144 }
18145
18146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18147         LDKDecodeError e_conv;
18148         e_conv.inner = (void*)(e & (~1));
18149         e_conv.is_owned = (e & 1) || (e == 0);
18150         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18151         e_conv = DecodeError_clone(&e_conv);
18152         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18153         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18154         return (int64_t)ret_conv;
18155 }
18156
18157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18158         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18159         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18160         return ret_conv;
18161 }
18162
18163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18164         if ((_res & 1) != 0) return;
18165         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18166         CHECK_ACCESS(_res_ptr);
18167         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18168         FREE((void*)_res);
18169         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18170 }
18171
18172 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18173         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18174         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18175         return (int64_t)ret_conv;
18176 }
18177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18178         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18179         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18180         return ret_conv;
18181 }
18182
18183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18184         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18185         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18186         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18187         return (int64_t)ret_conv;
18188 }
18189
18190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18191         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18192         CHECK_ACCESS(o_ptr);
18193         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
18194         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
18195         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18196         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
18197         return (int64_t)ret_conv;
18198 }
18199
18200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18201         LDKDecodeError e_conv;
18202         e_conv.inner = (void*)(e & (~1));
18203         e_conv.is_owned = (e & 1) || (e == 0);
18204         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18205         e_conv = DecodeError_clone(&e_conv);
18206         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18207         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
18208         return (int64_t)ret_conv;
18209 }
18210
18211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18212         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
18213         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18214         return ret_conv;
18215 }
18216
18217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18218         if ((_res & 1) != 0) return;
18219         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18220         CHECK_ACCESS(_res_ptr);
18221         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
18222         FREE((void*)_res);
18223         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
18224 }
18225
18226 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18227         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18228         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
18229         return (int64_t)ret_conv;
18230 }
18231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18232         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
18233         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18234         return ret_conv;
18235 }
18236
18237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18238         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
18239         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18240         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
18241         return (int64_t)ret_conv;
18242 }
18243
18244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18245         LDKCVec_PaymentPreimageZ _res_constr;
18246         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18247         if (_res_constr.datalen > 0)
18248                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
18249         else
18250                 _res_constr.data = NULL;
18251         for (size_t i = 0; i < _res_constr.datalen; i++) {
18252                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18253                 LDKThirtyTwoBytes _res_conv_8_ref;
18254                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
18255                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
18256                 _res_constr.data[i] = _res_conv_8_ref;
18257         }
18258         CVec_PaymentPreimageZ_free(_res_constr);
18259 }
18260
18261 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
18262         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18263         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
18264         return ((int64_t)ret_conv);
18265 }
18266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18267         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
18268         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
18269         return ret_conv;
18270 }
18271
18272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18273         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
18274         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18275         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
18276         return ((int64_t)ret_conv);
18277 }
18278
18279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
18280         LDKSignature a_ref;
18281         CHECK((*env)->GetArrayLength(env, a) == 64);
18282         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18283         LDKCVec_SignatureZ b_constr;
18284         b_constr.datalen = (*env)->GetArrayLength(env, b);
18285         if (b_constr.datalen > 0)
18286                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18287         else
18288                 b_constr.data = NULL;
18289         for (size_t i = 0; i < b_constr.datalen; i++) {
18290                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
18291                 LDKSignature b_conv_8_ref;
18292                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
18293                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
18294                 b_constr.data[i] = b_conv_8_ref;
18295         }
18296         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18297         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
18298         return ((int64_t)ret_conv);
18299 }
18300
18301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18302         if ((_res & 1) != 0) return;
18303         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18304         CHECK_ACCESS(_res_ptr);
18305         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
18306         FREE((void*)_res);
18307         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
18308 }
18309
18310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18311         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18312         CHECK_ACCESS(o_ptr);
18313         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
18314         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
18315         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18316         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
18317         return (int64_t)ret_conv;
18318 }
18319
18320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
18321         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18322         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
18323         return (int64_t)ret_conv;
18324 }
18325
18326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18327         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
18328         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
18329         return ret_conv;
18330 }
18331
18332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18333         if ((_res & 1) != 0) return;
18334         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18335         CHECK_ACCESS(_res_ptr);
18336         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
18337         FREE((void*)_res);
18338         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
18339 }
18340
18341 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
18342         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18343         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
18344         return (int64_t)ret_conv;
18345 }
18346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18347         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
18348         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
18349         return ret_conv;
18350 }
18351
18352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18353         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
18354         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18355         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
18356         return (int64_t)ret_conv;
18357 }
18358
18359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18360         LDKSignature o_ref;
18361         CHECK((*env)->GetArrayLength(env, o) == 64);
18362         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
18363         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18364         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
18365         return (int64_t)ret_conv;
18366 }
18367
18368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18369         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18370         *ret_conv = CResult_SignatureNoneZ_err();
18371         return (int64_t)ret_conv;
18372 }
18373
18374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18375         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
18376         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
18377         return ret_conv;
18378 }
18379
18380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18381         if ((_res & 1) != 0) return;
18382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18383         CHECK_ACCESS(_res_ptr);
18384         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
18385         FREE((void*)_res);
18386         CResult_SignatureNoneZ_free(_res_conv);
18387 }
18388
18389 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
18390         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18391         *ret_conv = CResult_SignatureNoneZ_clone(arg);
18392         return (int64_t)ret_conv;
18393 }
18394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18395         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
18396         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
18397         return ret_conv;
18398 }
18399
18400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18401         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
18402         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18403         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
18404         return (int64_t)ret_conv;
18405 }
18406
18407 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
18408         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18409         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
18410         return ((int64_t)ret_conv);
18411 }
18412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18413         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
18414         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
18415         return ret_conv;
18416 }
18417
18418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18419         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
18420         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18421         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
18422         return ((int64_t)ret_conv);
18423 }
18424
18425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18426         LDKSignature a_ref;
18427         CHECK((*env)->GetArrayLength(env, a) == 64);
18428         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18429         LDKSignature b_ref;
18430         CHECK((*env)->GetArrayLength(env, b) == 64);
18431         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
18432         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18433         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
18434         return ((int64_t)ret_conv);
18435 }
18436
18437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18438         if ((_res & 1) != 0) return;
18439         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18440         CHECK_ACCESS(_res_ptr);
18441         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
18442         FREE((void*)_res);
18443         C2Tuple_SignatureSignatureZ_free(_res_conv);
18444 }
18445
18446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18447         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18448         CHECK_ACCESS(o_ptr);
18449         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
18450         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
18451         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18452         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
18453         return (int64_t)ret_conv;
18454 }
18455
18456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
18457         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18458         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
18459         return (int64_t)ret_conv;
18460 }
18461
18462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18463         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
18464         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
18465         return ret_conv;
18466 }
18467
18468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18469         if ((_res & 1) != 0) return;
18470         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18471         CHECK_ACCESS(_res_ptr);
18472         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
18473         FREE((void*)_res);
18474         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
18475 }
18476
18477 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
18478         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18479         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
18480         return (int64_t)ret_conv;
18481 }
18482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18483         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
18484         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
18485         return ret_conv;
18486 }
18487
18488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18489         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
18490         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18491         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
18492         return (int64_t)ret_conv;
18493 }
18494
18495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18496         LDKSecretKey o_ref;
18497         CHECK((*env)->GetArrayLength(env, o) == 32);
18498         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
18499         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18500         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
18501         return (int64_t)ret_conv;
18502 }
18503
18504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
18505         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18506         *ret_conv = CResult_SecretKeyNoneZ_err();
18507         return (int64_t)ret_conv;
18508 }
18509
18510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18511         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
18512         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
18513         return ret_conv;
18514 }
18515
18516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18517         if ((_res & 1) != 0) return;
18518         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18519         CHECK_ACCESS(_res_ptr);
18520         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
18521         FREE((void*)_res);
18522         CResult_SecretKeyNoneZ_free(_res_conv);
18523 }
18524
18525 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
18526         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18527         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
18528         return (int64_t)ret_conv;
18529 }
18530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18531         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
18532         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
18533         return ret_conv;
18534 }
18535
18536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18537         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
18538         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18539         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
18540         return (int64_t)ret_conv;
18541 }
18542
18543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18544         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18545         CHECK_ACCESS(o_ptr);
18546         LDKSign o_conv = *(LDKSign*)(o_ptr);
18547         if (o_conv.free == LDKSign_JCalls_free) {
18548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18549                 LDKSign_JCalls_cloned(&o_conv);
18550         }
18551         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18552         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
18553         return (int64_t)ret_conv;
18554 }
18555
18556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18557         LDKDecodeError e_conv;
18558         e_conv.inner = (void*)(e & (~1));
18559         e_conv.is_owned = (e & 1) || (e == 0);
18560         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18561         e_conv = DecodeError_clone(&e_conv);
18562         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18563         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
18564         return (int64_t)ret_conv;
18565 }
18566
18567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18568         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
18569         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
18570         return ret_conv;
18571 }
18572
18573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18574         if ((_res & 1) != 0) return;
18575         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18576         CHECK_ACCESS(_res_ptr);
18577         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
18578         FREE((void*)_res);
18579         CResult_SignDecodeErrorZ_free(_res_conv);
18580 }
18581
18582 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
18583         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18584         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
18585         return (int64_t)ret_conv;
18586 }
18587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18588         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
18589         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
18590         return ret_conv;
18591 }
18592
18593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18594         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
18595         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18596         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
18597         return (int64_t)ret_conv;
18598 }
18599
18600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18601         LDKCVec_u5Z _res_constr;
18602         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18603         if (_res_constr.datalen > 0)
18604                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
18605         else
18606                 _res_constr.data = NULL;
18607         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
18608         for (size_t h = 0; h < _res_constr.datalen; h++) {
18609                 int8_t _res_conv_7 = _res_vals[h];
18610                 
18611                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
18612         }
18613         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
18614         CVec_u5Z_free(_res_constr);
18615 }
18616
18617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18618         LDKRecoverableSignature o_ref;
18619         CHECK((*env)->GetArrayLength(env, o) == 68);
18620         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
18621         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18622         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
18623         return (int64_t)ret_conv;
18624 }
18625
18626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18627         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18628         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
18629         return (int64_t)ret_conv;
18630 }
18631
18632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18633         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
18634         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
18635         return ret_conv;
18636 }
18637
18638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18639         if ((_res & 1) != 0) return;
18640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18641         CHECK_ACCESS(_res_ptr);
18642         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
18643         FREE((void*)_res);
18644         CResult_RecoverableSignatureNoneZ_free(_res_conv);
18645 }
18646
18647 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
18648         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18649         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
18650         return (int64_t)ret_conv;
18651 }
18652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18653         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
18654         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
18655         return ret_conv;
18656 }
18657
18658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18659         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
18660         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18661         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
18662         return (int64_t)ret_conv;
18663 }
18664
18665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
18666         LDKCVec_u8Z _res_ref;
18667         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
18668         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
18669         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
18670         CVec_u8Z_free(_res_ref);
18671 }
18672
18673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18674         LDKCVec_CVec_u8ZZ _res_constr;
18675         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18676         if (_res_constr.datalen > 0)
18677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
18678         else
18679                 _res_constr.data = NULL;
18680         for (size_t i = 0; i < _res_constr.datalen; i++) {
18681                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18682                 LDKCVec_u8Z _res_conv_8_ref;
18683                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
18684                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
18685                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
18686                 _res_constr.data[i] = _res_conv_8_ref;
18687         }
18688         CVec_CVec_u8ZZ_free(_res_constr);
18689 }
18690
18691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
18692         LDKCVec_CVec_u8ZZ o_constr;
18693         o_constr.datalen = (*env)->GetArrayLength(env, o);
18694         if (o_constr.datalen > 0)
18695                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
18696         else
18697                 o_constr.data = NULL;
18698         for (size_t i = 0; i < o_constr.datalen; i++) {
18699                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
18700                 LDKCVec_u8Z o_conv_8_ref;
18701                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
18702                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
18703                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
18704                 o_constr.data[i] = o_conv_8_ref;
18705         }
18706         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18707         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
18708         return (int64_t)ret_conv;
18709 }
18710
18711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
18712         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18713         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
18714         return (int64_t)ret_conv;
18715 }
18716
18717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18718         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
18719         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
18720         return ret_conv;
18721 }
18722
18723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18724         if ((_res & 1) != 0) return;
18725         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18726         CHECK_ACCESS(_res_ptr);
18727         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
18728         FREE((void*)_res);
18729         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
18730 }
18731
18732 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
18733         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18734         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
18735         return (int64_t)ret_conv;
18736 }
18737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18738         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
18739         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
18740         return ret_conv;
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18744         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
18745         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18746         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
18747         return (int64_t)ret_conv;
18748 }
18749
18750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18751         LDKInMemorySigner o_conv;
18752         o_conv.inner = (void*)(o & (~1));
18753         o_conv.is_owned = (o & 1) || (o == 0);
18754         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18755         o_conv = InMemorySigner_clone(&o_conv);
18756         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18757         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
18758         return (int64_t)ret_conv;
18759 }
18760
18761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18762         LDKDecodeError e_conv;
18763         e_conv.inner = (void*)(e & (~1));
18764         e_conv.is_owned = (e & 1) || (e == 0);
18765         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18766         e_conv = DecodeError_clone(&e_conv);
18767         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18768         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
18769         return (int64_t)ret_conv;
18770 }
18771
18772 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18773         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
18774         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
18775         return ret_conv;
18776 }
18777
18778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18779         if ((_res & 1) != 0) return;
18780         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18781         CHECK_ACCESS(_res_ptr);
18782         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
18783         FREE((void*)_res);
18784         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
18785 }
18786
18787 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
18788         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18789         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
18790         return (int64_t)ret_conv;
18791 }
18792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18793         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
18794         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
18795         return ret_conv;
18796 }
18797
18798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18799         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
18800         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18801         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
18802         return (int64_t)ret_conv;
18803 }
18804
18805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18806         LDKCVec_TxOutZ _res_constr;
18807         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18808         if (_res_constr.datalen > 0)
18809                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
18810         else
18811                 _res_constr.data = NULL;
18812         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18813         for (size_t h = 0; h < _res_constr.datalen; h++) {
18814                 int64_t _res_conv_7 = _res_vals[h];
18815                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
18816                 CHECK_ACCESS(_res_conv_7_ptr);
18817                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
18818                 FREE((void*)_res_conv_7);
18819                 _res_constr.data[h] = _res_conv_7_conv;
18820         }
18821         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18822         CVec_TxOutZ_free(_res_constr);
18823 }
18824
18825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18826         LDKTransaction o_ref;
18827         o_ref.datalen = (*env)->GetArrayLength(env, o);
18828         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
18829         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
18830         o_ref.data_is_owned = true;
18831         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18832         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
18833         return (int64_t)ret_conv;
18834 }
18835
18836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
18837         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18838         *ret_conv = CResult_TransactionNoneZ_err();
18839         return (int64_t)ret_conv;
18840 }
18841
18842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18843         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
18844         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
18845         return ret_conv;
18846 }
18847
18848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18849         if ((_res & 1) != 0) return;
18850         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18851         CHECK_ACCESS(_res_ptr);
18852         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
18853         FREE((void*)_res);
18854         CResult_TransactionNoneZ_free(_res_conv);
18855 }
18856
18857 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
18858         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18859         *ret_conv = CResult_TransactionNoneZ_clone(arg);
18860         return (int64_t)ret_conv;
18861 }
18862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18863         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
18864         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
18865         return ret_conv;
18866 }
18867
18868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18869         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
18870         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18871         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
18872         return (int64_t)ret_conv;
18873 }
18874
18875 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18876         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18877         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18878         return ((int64_t)ret_conv);
18879 }
18880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18881         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
18882         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18883         return ret_conv;
18884 }
18885
18886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18887         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
18888         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18889         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18890         return ((int64_t)ret_conv);
18891 }
18892
18893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18894         LDKThirtyTwoBytes a_ref;
18895         CHECK((*env)->GetArrayLength(env, a) == 32);
18896         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18897         LDKChannelMonitor b_conv;
18898         b_conv.inner = (void*)(b & (~1));
18899         b_conv.is_owned = (b & 1) || (b == 0);
18900         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18901         b_conv = ChannelMonitor_clone(&b_conv);
18902         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18903         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18904         return ((int64_t)ret_conv);
18905 }
18906
18907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18908         if ((_res & 1) != 0) return;
18909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18910         CHECK_ACCESS(_res_ptr);
18911         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18912         FREE((void*)_res);
18913         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18914 }
18915
18916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18917         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
18918         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18919         if (_res_constr.datalen > 0)
18920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18921         else
18922                 _res_constr.data = NULL;
18923         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18924         for (size_t j = 0; j < _res_constr.datalen; j++) {
18925                 int64_t _res_conv_35 = _res_vals[j];
18926                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
18927                 CHECK_ACCESS(_res_conv_35_ptr);
18928                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
18929                 FREE((void*)_res_conv_35);
18930                 _res_constr.data[j] = _res_conv_35_conv;
18931         }
18932         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18933         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
18934 }
18935
18936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
18937         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
18938         o_constr.datalen = (*env)->GetArrayLength(env, o);
18939         if (o_constr.datalen > 0)
18940                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18941         else
18942                 o_constr.data = NULL;
18943         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18944         for (size_t j = 0; j < o_constr.datalen; j++) {
18945                 int64_t o_conv_35 = o_vals[j];
18946                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
18947                 CHECK_ACCESS(o_conv_35_ptr);
18948                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
18949                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
18950                 o_constr.data[j] = o_conv_35_conv;
18951         }
18952         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18953         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18954         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
18955         return (int64_t)ret_conv;
18956 }
18957
18958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18959         LDKIOError e_conv = LDKIOError_from_java(env, e);
18960         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18961         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
18962         return (int64_t)ret_conv;
18963 }
18964
18965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18966         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
18967         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
18968         return ret_conv;
18969 }
18970
18971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18972         if ((_res & 1) != 0) return;
18973         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18974         CHECK_ACCESS(_res_ptr);
18975         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
18976         FREE((void*)_res);
18977         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
18978 }
18979
18980 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
18981         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18982         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
18983         return (int64_t)ret_conv;
18984 }
18985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18986         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
18987         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
18988         return ret_conv;
18989 }
18990
18991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18992         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
18993         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18994         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
18995         return (int64_t)ret_conv;
18996 }
18997
18998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
18999         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19000         *ret_copy = COption_u16Z_some(o);
19001         int64_t ret_ref = (uintptr_t)ret_copy;
19002         return ret_ref;
19003 }
19004
19005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
19006         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19007         *ret_copy = COption_u16Z_none();
19008         int64_t ret_ref = (uintptr_t)ret_copy;
19009         return ret_ref;
19010 }
19011
19012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_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         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
19017         FREE((void*)_res);
19018         COption_u16Z_free(_res_conv);
19019 }
19020
19021 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
19022         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19023         *ret_copy = COption_u16Z_clone(arg);
19024 int64_t ret_ref = (uintptr_t)ret_copy;
19025         return ret_ref;
19026 }
19027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19028         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
19029         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
19030         return ret_conv;
19031 }
19032
19033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19034         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
19035         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19036         *ret_copy = COption_u16Z_clone(orig_conv);
19037         int64_t ret_ref = (uintptr_t)ret_copy;
19038         return ret_ref;
19039 }
19040
19041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
19042         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19043         *ret_conv = CResult_NoneAPIErrorZ_ok();
19044         return (int64_t)ret_conv;
19045 }
19046
19047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19048         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19049         CHECK_ACCESS(e_ptr);
19050         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19051         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19052         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19053         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
19054         return (int64_t)ret_conv;
19055 }
19056
19057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19058         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
19059         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
19060         return ret_conv;
19061 }
19062
19063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19064         if ((_res & 1) != 0) return;
19065         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19066         CHECK_ACCESS(_res_ptr);
19067         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
19068         FREE((void*)_res);
19069         CResult_NoneAPIErrorZ_free(_res_conv);
19070 }
19071
19072 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
19073         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19074         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
19075         return (int64_t)ret_conv;
19076 }
19077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19078         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
19079         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
19080         return ret_conv;
19081 }
19082
19083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19084         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
19085         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19086         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
19087         return (int64_t)ret_conv;
19088 }
19089
19090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19091         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
19092         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19093         if (_res_constr.datalen > 0)
19094                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19095         else
19096                 _res_constr.data = NULL;
19097         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19098         for (size_t w = 0; w < _res_constr.datalen; w++) {
19099                 int64_t _res_conv_22 = _res_vals[w];
19100                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
19101                 CHECK_ACCESS(_res_conv_22_ptr);
19102                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
19103                 FREE((void*)_res_conv_22);
19104                 _res_constr.data[w] = _res_conv_22_conv;
19105         }
19106         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19107         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
19108 }
19109
19110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19111         LDKCVec_APIErrorZ _res_constr;
19112         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19113         if (_res_constr.datalen > 0)
19114                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19115         else
19116                 _res_constr.data = NULL;
19117         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19118         for (size_t k = 0; k < _res_constr.datalen; k++) {
19119                 int64_t _res_conv_10 = _res_vals[k];
19120                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
19121                 CHECK_ACCESS(_res_conv_10_ptr);
19122                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
19123                 FREE((void*)_res_conv_10);
19124                 _res_constr.data[k] = _res_conv_10_conv;
19125         }
19126         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19127         CVec_APIErrorZ_free(_res_constr);
19128 }
19129
19130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19131         LDKThirtyTwoBytes o_ref;
19132         CHECK((*env)->GetArrayLength(env, o) == 32);
19133         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19134         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19135         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
19136         return (int64_t)ret_conv;
19137 }
19138
19139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19140         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19141         CHECK_ACCESS(e_ptr);
19142         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19143         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19144         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19145         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
19146         return (int64_t)ret_conv;
19147 }
19148
19149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19150         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
19151         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
19152         return ret_conv;
19153 }
19154
19155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19156         if ((_res & 1) != 0) return;
19157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19158         CHECK_ACCESS(_res_ptr);
19159         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
19160         FREE((void*)_res);
19161         CResult__u832APIErrorZ_free(_res_conv);
19162 }
19163
19164 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
19165         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19166         *ret_conv = CResult__u832APIErrorZ_clone(arg);
19167         return (int64_t)ret_conv;
19168 }
19169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19170         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
19171         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
19172         return ret_conv;
19173 }
19174
19175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19176         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
19177         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19178         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
19179         return (int64_t)ret_conv;
19180 }
19181
19182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19183         LDKThirtyTwoBytes o_ref;
19184         CHECK((*env)->GetArrayLength(env, o) == 32);
19185         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19186         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19187         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
19188         return (int64_t)ret_conv;
19189 }
19190
19191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19192         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19193         CHECK_ACCESS(e_ptr);
19194         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19195         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19196         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19197         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
19198         return (int64_t)ret_conv;
19199 }
19200
19201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19202         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
19203         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
19204         return ret_conv;
19205 }
19206
19207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19208         if ((_res & 1) != 0) return;
19209         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19210         CHECK_ACCESS(_res_ptr);
19211         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
19212         FREE((void*)_res);
19213         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
19214 }
19215
19216 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
19217         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19218         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
19219         return (int64_t)ret_conv;
19220 }
19221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19222         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
19223         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
19224         return ret_conv;
19225 }
19226
19227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19228         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
19229         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19230         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
19231         return (int64_t)ret_conv;
19232 }
19233
19234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
19235         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19236         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
19237         return (int64_t)ret_conv;
19238 }
19239
19240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19241         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19242         CHECK_ACCESS(e_ptr);
19243         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19244         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19245         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19246         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
19247         return (int64_t)ret_conv;
19248 }
19249
19250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19251         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
19252         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
19253         return ret_conv;
19254 }
19255
19256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19257         if ((_res & 1) != 0) return;
19258         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19259         CHECK_ACCESS(_res_ptr);
19260         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
19261         FREE((void*)_res);
19262         CResult_NonePaymentSendFailureZ_free(_res_conv);
19263 }
19264
19265 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
19266         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19267         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
19268         return (int64_t)ret_conv;
19269 }
19270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19271         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
19272         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
19273         return ret_conv;
19274 }
19275
19276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19277         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
19278         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19279         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
19280         return (int64_t)ret_conv;
19281 }
19282
19283 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
19284         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19285         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
19286         return ((int64_t)ret_conv);
19287 }
19288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19289         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
19290         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
19291         return ret_conv;
19292 }
19293
19294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19295         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
19296         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19297         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
19298         return ((int64_t)ret_conv);
19299 }
19300
19301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19302         LDKThirtyTwoBytes a_ref;
19303         CHECK((*env)->GetArrayLength(env, a) == 32);
19304         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19305         LDKThirtyTwoBytes b_ref;
19306         CHECK((*env)->GetArrayLength(env, b) == 32);
19307         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19308         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19309         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
19310         return ((int64_t)ret_conv);
19311 }
19312
19313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19314         if ((_res & 1) != 0) return;
19315         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19316         CHECK_ACCESS(_res_ptr);
19317         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
19318         FREE((void*)_res);
19319         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
19320 }
19321
19322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19324         CHECK_ACCESS(o_ptr);
19325         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
19326         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
19327         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19328         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
19329         return (int64_t)ret_conv;
19330 }
19331
19332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19333         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19334         CHECK_ACCESS(e_ptr);
19335         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19336         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19337         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19338         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
19339         return (int64_t)ret_conv;
19340 }
19341
19342 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19343         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
19344         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
19345         return ret_conv;
19346 }
19347
19348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19349         if ((_res & 1) != 0) return;
19350         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19351         CHECK_ACCESS(_res_ptr);
19352         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
19353         FREE((void*)_res);
19354         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
19355 }
19356
19357 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
19358         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19359         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
19360         return (int64_t)ret_conv;
19361 }
19362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19363         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
19364         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
19365         return ret_conv;
19366 }
19367
19368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19369         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
19370         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19371         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
19372         return (int64_t)ret_conv;
19373 }
19374
19375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19376         LDKCVec_ThirtyTwoBytesZ _res_constr;
19377         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19378         if (_res_constr.datalen > 0)
19379                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
19380         else
19381                 _res_constr.data = NULL;
19382         for (size_t i = 0; i < _res_constr.datalen; i++) {
19383                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19384                 LDKThirtyTwoBytes _res_conv_8_ref;
19385                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19386                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19387                 _res_constr.data[i] = _res_conv_8_ref;
19388         }
19389         CVec_ThirtyTwoBytesZ_free(_res_constr);
19390 }
19391
19392 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
19393         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19394         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
19395         return ((int64_t)ret_conv);
19396 }
19397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19398         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
19399         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
19400         return ret_conv;
19401 }
19402
19403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19404         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
19405         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19406         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
19407         return ((int64_t)ret_conv);
19408 }
19409
19410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19411         LDKThirtyTwoBytes a_ref;
19412         CHECK((*env)->GetArrayLength(env, a) == 32);
19413         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19414         LDKThirtyTwoBytes b_ref;
19415         CHECK((*env)->GetArrayLength(env, b) == 32);
19416         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19417         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19418         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
19419         return ((int64_t)ret_conv);
19420 }
19421
19422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19423         if ((_res & 1) != 0) return;
19424         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19425         CHECK_ACCESS(_res_ptr);
19426         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
19427         FREE((void*)_res);
19428         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
19429 }
19430
19431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19432         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19433         CHECK_ACCESS(o_ptr);
19434         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19435         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19436         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19437         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
19438         return (int64_t)ret_conv;
19439 }
19440
19441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
19442         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19443         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
19444         return (int64_t)ret_conv;
19445 }
19446
19447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19448         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
19449         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
19450         return ret_conv;
19451 }
19452
19453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19454         if ((_res & 1) != 0) return;
19455         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19456         CHECK_ACCESS(_res_ptr);
19457         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
19458         FREE((void*)_res);
19459         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
19460 }
19461
19462 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
19463         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19464         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
19465         return (int64_t)ret_conv;
19466 }
19467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19468         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
19469         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
19470         return ret_conv;
19471 }
19472
19473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19474         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
19475         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19476         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
19477         return (int64_t)ret_conv;
19478 }
19479
19480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19481         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19482         CHECK_ACCESS(o_ptr);
19483         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19484         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19485         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19486         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
19487         return (int64_t)ret_conv;
19488 }
19489
19490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19491         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19492         CHECK_ACCESS(e_ptr);
19493         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19494         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19495         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19496         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
19497         return (int64_t)ret_conv;
19498 }
19499
19500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19501         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
19502         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
19503         return ret_conv;
19504 }
19505
19506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19507         if ((_res & 1) != 0) return;
19508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19509         CHECK_ACCESS(_res_ptr);
19510         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
19511         FREE((void*)_res);
19512         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
19513 }
19514
19515 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
19516         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19517         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
19518         return (int64_t)ret_conv;
19519 }
19520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19521         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
19522         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
19523         return ret_conv;
19524 }
19525
19526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19527         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
19528         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19529         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
19530         return (int64_t)ret_conv;
19531 }
19532
19533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19534         LDKThirtyTwoBytes o_ref;
19535         CHECK((*env)->GetArrayLength(env, o) == 32);
19536         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19537         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19538         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
19539         return (int64_t)ret_conv;
19540 }
19541
19542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19543         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19544         *ret_conv = CResult_PaymentSecretNoneZ_err();
19545         return (int64_t)ret_conv;
19546 }
19547
19548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19549         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
19550         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
19551         return ret_conv;
19552 }
19553
19554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19555         if ((_res & 1) != 0) return;
19556         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19557         CHECK_ACCESS(_res_ptr);
19558         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
19559         FREE((void*)_res);
19560         CResult_PaymentSecretNoneZ_free(_res_conv);
19561 }
19562
19563 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
19564         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19565         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
19566         return (int64_t)ret_conv;
19567 }
19568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19569         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
19570         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
19571         return ret_conv;
19572 }
19573
19574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19575         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
19576         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19577         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
19578         return (int64_t)ret_conv;
19579 }
19580
19581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19582         LDKThirtyTwoBytes o_ref;
19583         CHECK((*env)->GetArrayLength(env, o) == 32);
19584         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19585         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19586         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
19587         return (int64_t)ret_conv;
19588 }
19589
19590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19591         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19592         CHECK_ACCESS(e_ptr);
19593         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19594         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19595         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19596         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
19597         return (int64_t)ret_conv;
19598 }
19599
19600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19601         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
19602         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
19603         return ret_conv;
19604 }
19605
19606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19607         if ((_res & 1) != 0) return;
19608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19609         CHECK_ACCESS(_res_ptr);
19610         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
19611         FREE((void*)_res);
19612         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
19613 }
19614
19615 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
19616         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19617         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
19618         return (int64_t)ret_conv;
19619 }
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19621         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
19622         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
19623         return ret_conv;
19624 }
19625
19626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19627         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
19628         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19629         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
19630         return (int64_t)ret_conv;
19631 }
19632
19633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19634         LDKThirtyTwoBytes o_ref;
19635         CHECK((*env)->GetArrayLength(env, o) == 32);
19636         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19637         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19638         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
19639         return (int64_t)ret_conv;
19640 }
19641
19642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19643         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19644         CHECK_ACCESS(e_ptr);
19645         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19646         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19647         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19648         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
19649         return (int64_t)ret_conv;
19650 }
19651
19652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19653         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
19654         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
19655         return ret_conv;
19656 }
19657
19658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19659         if ((_res & 1) != 0) return;
19660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19661         CHECK_ACCESS(_res_ptr);
19662         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
19663         FREE((void*)_res);
19664         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
19665 }
19666
19667 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
19668         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19669         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
19670         return (int64_t)ret_conv;
19671 }
19672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19673         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
19674         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
19675         return ret_conv;
19676 }
19677
19678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19679         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
19680         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19681         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
19682         return (int64_t)ret_conv;
19683 }
19684
19685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19686         LDKCounterpartyForwardingInfo o_conv;
19687         o_conv.inner = (void*)(o & (~1));
19688         o_conv.is_owned = (o & 1) || (o == 0);
19689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19690         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
19691         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19692         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
19693         return (int64_t)ret_conv;
19694 }
19695
19696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19697         LDKDecodeError e_conv;
19698         e_conv.inner = (void*)(e & (~1));
19699         e_conv.is_owned = (e & 1) || (e == 0);
19700         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19701         e_conv = DecodeError_clone(&e_conv);
19702         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19703         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
19704         return (int64_t)ret_conv;
19705 }
19706
19707 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19708         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
19709         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
19710         return ret_conv;
19711 }
19712
19713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19714         if ((_res & 1) != 0) return;
19715         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19716         CHECK_ACCESS(_res_ptr);
19717         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
19718         FREE((void*)_res);
19719         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
19720 }
19721
19722 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
19723         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19724         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
19725         return (int64_t)ret_conv;
19726 }
19727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19728         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
19729         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
19730         return ret_conv;
19731 }
19732
19733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19734         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
19735         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19736         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
19737         return (int64_t)ret_conv;
19738 }
19739
19740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19741         LDKChannelCounterparty o_conv;
19742         o_conv.inner = (void*)(o & (~1));
19743         o_conv.is_owned = (o & 1) || (o == 0);
19744         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19745         o_conv = ChannelCounterparty_clone(&o_conv);
19746         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19747         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
19748         return (int64_t)ret_conv;
19749 }
19750
19751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19752         LDKDecodeError e_conv;
19753         e_conv.inner = (void*)(e & (~1));
19754         e_conv.is_owned = (e & 1) || (e == 0);
19755         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19756         e_conv = DecodeError_clone(&e_conv);
19757         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19758         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
19759         return (int64_t)ret_conv;
19760 }
19761
19762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19763         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
19764         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
19765         return ret_conv;
19766 }
19767
19768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19769         if ((_res & 1) != 0) return;
19770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19771         CHECK_ACCESS(_res_ptr);
19772         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
19773         FREE((void*)_res);
19774         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
19775 }
19776
19777 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
19778         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19779         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
19780         return (int64_t)ret_conv;
19781 }
19782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19783         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
19784         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
19785         return ret_conv;
19786 }
19787
19788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19789         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
19790         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19791         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
19792         return (int64_t)ret_conv;
19793 }
19794
19795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19796         LDKChannelDetails o_conv;
19797         o_conv.inner = (void*)(o & (~1));
19798         o_conv.is_owned = (o & 1) || (o == 0);
19799         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19800         o_conv = ChannelDetails_clone(&o_conv);
19801         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19802         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
19803         return (int64_t)ret_conv;
19804 }
19805
19806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19807         LDKDecodeError e_conv;
19808         e_conv.inner = (void*)(e & (~1));
19809         e_conv.is_owned = (e & 1) || (e == 0);
19810         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19811         e_conv = DecodeError_clone(&e_conv);
19812         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19813         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
19814         return (int64_t)ret_conv;
19815 }
19816
19817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19818         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
19819         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
19820         return ret_conv;
19821 }
19822
19823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19824         if ((_res & 1) != 0) return;
19825         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19826         CHECK_ACCESS(_res_ptr);
19827         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
19828         FREE((void*)_res);
19829         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
19830 }
19831
19832 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
19833         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19834         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
19835         return (int64_t)ret_conv;
19836 }
19837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19838         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
19839         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
19840         return ret_conv;
19841 }
19842
19843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19844         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
19845         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19846         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
19847         return (int64_t)ret_conv;
19848 }
19849
19850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19851         LDKPhantomRouteHints o_conv;
19852         o_conv.inner = (void*)(o & (~1));
19853         o_conv.is_owned = (o & 1) || (o == 0);
19854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19855         o_conv = PhantomRouteHints_clone(&o_conv);
19856         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19857         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
19858         return (int64_t)ret_conv;
19859 }
19860
19861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19862         LDKDecodeError e_conv;
19863         e_conv.inner = (void*)(e & (~1));
19864         e_conv.is_owned = (e & 1) || (e == 0);
19865         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19866         e_conv = DecodeError_clone(&e_conv);
19867         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19868         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
19869         return (int64_t)ret_conv;
19870 }
19871
19872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19873         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
19874         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
19875         return ret_conv;
19876 }
19877
19878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19879         if ((_res & 1) != 0) return;
19880         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19881         CHECK_ACCESS(_res_ptr);
19882         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
19883         FREE((void*)_res);
19884         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
19885 }
19886
19887 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
19888         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19889         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
19890         return (int64_t)ret_conv;
19891 }
19892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19893         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
19894         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
19895         return ret_conv;
19896 }
19897
19898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19899         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
19900         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19901         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
19902         return (int64_t)ret_conv;
19903 }
19904
19905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19906         LDKCVec_ChannelMonitorZ _res_constr;
19907         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19908         if (_res_constr.datalen > 0)
19909                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
19910         else
19911                 _res_constr.data = NULL;
19912         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19913         for (size_t q = 0; q < _res_constr.datalen; q++) {
19914                 int64_t _res_conv_16 = _res_vals[q];
19915                 LDKChannelMonitor _res_conv_16_conv;
19916                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
19917                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
19918                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
19919                 _res_constr.data[q] = _res_conv_16_conv;
19920         }
19921         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19922         CVec_ChannelMonitorZ_free(_res_constr);
19923 }
19924
19925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19926         LDKThirtyTwoBytes a_ref;
19927         CHECK((*env)->GetArrayLength(env, a) == 32);
19928         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19929         LDKChannelManager b_conv;
19930         b_conv.inner = (void*)(b & (~1));
19931         b_conv.is_owned = (b & 1) || (b == 0);
19932         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19933         // WARNING: we need a move here but no clone is available for LDKChannelManager
19934         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
19935         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
19936         return ((int64_t)ret_conv);
19937 }
19938
19939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19940         if ((_res & 1) != 0) return;
19941         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19942         CHECK_ACCESS(_res_ptr);
19943         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
19944         FREE((void*)_res);
19945         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
19946 }
19947
19948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19949         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19950         CHECK_ACCESS(o_ptr);
19951         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
19952         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
19953         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19954         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
19955         return (int64_t)ret_conv;
19956 }
19957
19958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19959         LDKDecodeError e_conv;
19960         e_conv.inner = (void*)(e & (~1));
19961         e_conv.is_owned = (e & 1) || (e == 0);
19962         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19963         e_conv = DecodeError_clone(&e_conv);
19964         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19965         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
19966         return (int64_t)ret_conv;
19967 }
19968
19969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19970         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
19971         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
19972         return ret_conv;
19973 }
19974
19975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19976         if ((_res & 1) != 0) return;
19977         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19978         CHECK_ACCESS(_res_ptr);
19979         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
19980         FREE((void*)_res);
19981         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
19982 }
19983
19984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19985         LDKChannelConfig o_conv;
19986         o_conv.inner = (void*)(o & (~1));
19987         o_conv.is_owned = (o & 1) || (o == 0);
19988         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19989         o_conv = ChannelConfig_clone(&o_conv);
19990         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19991         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
19992         return (int64_t)ret_conv;
19993 }
19994
19995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19996         LDKDecodeError e_conv;
19997         e_conv.inner = (void*)(e & (~1));
19998         e_conv.is_owned = (e & 1) || (e == 0);
19999         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20000         e_conv = DecodeError_clone(&e_conv);
20001         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20002         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
20003         return (int64_t)ret_conv;
20004 }
20005
20006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20007         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
20008         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
20009         return ret_conv;
20010 }
20011
20012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20013         if ((_res & 1) != 0) return;
20014         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20015         CHECK_ACCESS(_res_ptr);
20016         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
20017         FREE((void*)_res);
20018         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
20019 }
20020
20021 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
20022         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20023         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
20024         return (int64_t)ret_conv;
20025 }
20026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20027         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
20028         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
20029         return ret_conv;
20030 }
20031
20032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20033         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
20034         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20035         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
20036         return (int64_t)ret_conv;
20037 }
20038
20039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20040         LDKOutPoint o_conv;
20041         o_conv.inner = (void*)(o & (~1));
20042         o_conv.is_owned = (o & 1) || (o == 0);
20043         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20044         o_conv = OutPoint_clone(&o_conv);
20045         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20046         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
20047         return (int64_t)ret_conv;
20048 }
20049
20050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20051         LDKDecodeError e_conv;
20052         e_conv.inner = (void*)(e & (~1));
20053         e_conv.is_owned = (e & 1) || (e == 0);
20054         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20055         e_conv = DecodeError_clone(&e_conv);
20056         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20057         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
20058         return (int64_t)ret_conv;
20059 }
20060
20061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20062         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
20063         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
20064         return ret_conv;
20065 }
20066
20067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20068         if ((_res & 1) != 0) return;
20069         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20070         CHECK_ACCESS(_res_ptr);
20071         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
20072         FREE((void*)_res);
20073         CResult_OutPointDecodeErrorZ_free(_res_conv);
20074 }
20075
20076 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
20077         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20078         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
20079         return (int64_t)ret_conv;
20080 }
20081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20082         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
20083         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
20084         return ret_conv;
20085 }
20086
20087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20088         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
20089         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20090         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
20091         return (int64_t)ret_conv;
20092 }
20093
20094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20095         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20096         CHECK_ACCESS(o_ptr);
20097         LDKType o_conv = *(LDKType*)(o_ptr);
20098         if (o_conv.free == LDKType_JCalls_free) {
20099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20100                 LDKType_JCalls_cloned(&o_conv);
20101         }
20102         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20103         *ret_copy = COption_TypeZ_some(o_conv);
20104         int64_t ret_ref = (uintptr_t)ret_copy;
20105         return ret_ref;
20106 }
20107
20108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
20109         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20110         *ret_copy = COption_TypeZ_none();
20111         int64_t ret_ref = (uintptr_t)ret_copy;
20112         return ret_ref;
20113 }
20114
20115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20116         if ((_res & 1) != 0) return;
20117         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20118         CHECK_ACCESS(_res_ptr);
20119         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
20120         FREE((void*)_res);
20121         COption_TypeZ_free(_res_conv);
20122 }
20123
20124 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
20125         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20126         *ret_copy = COption_TypeZ_clone(arg);
20127 int64_t ret_ref = (uintptr_t)ret_copy;
20128         return ret_ref;
20129 }
20130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20131         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
20132         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
20133         return ret_conv;
20134 }
20135
20136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20137         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
20138         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20139         *ret_copy = COption_TypeZ_clone(orig_conv);
20140         int64_t ret_ref = (uintptr_t)ret_copy;
20141         return ret_ref;
20142 }
20143
20144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20145         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20146         CHECK_ACCESS(o_ptr);
20147         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
20148         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
20149         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20150         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
20151         return (int64_t)ret_conv;
20152 }
20153
20154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20155         LDKDecodeError e_conv;
20156         e_conv.inner = (void*)(e & (~1));
20157         e_conv.is_owned = (e & 1) || (e == 0);
20158         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20159         e_conv = DecodeError_clone(&e_conv);
20160         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20161         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
20162         return (int64_t)ret_conv;
20163 }
20164
20165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20166         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
20167         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
20168         return ret_conv;
20169 }
20170
20171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20172         if ((_res & 1) != 0) return;
20173         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20174         CHECK_ACCESS(_res_ptr);
20175         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
20176         FREE((void*)_res);
20177         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
20178 }
20179
20180 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
20181         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20182         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
20183         return (int64_t)ret_conv;
20184 }
20185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20186         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
20187         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
20188         return ret_conv;
20189 }
20190
20191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20192         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
20193         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20194         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
20195         return (int64_t)ret_conv;
20196 }
20197
20198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20199         LDKThirtyTwoBytes o_ref;
20200         CHECK((*env)->GetArrayLength(env, o) == 32);
20201         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20202         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20203         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
20204         return (int64_t)ret_conv;
20205 }
20206
20207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20208         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20209         CHECK_ACCESS(e_ptr);
20210         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
20211         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
20212         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20213         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
20214         return (int64_t)ret_conv;
20215 }
20216
20217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20218         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
20219         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
20220         return ret_conv;
20221 }
20222
20223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20224         if ((_res & 1) != 0) return;
20225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20226         CHECK_ACCESS(_res_ptr);
20227         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
20228         FREE((void*)_res);
20229         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
20230 }
20231
20232 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
20233         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20234         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
20235         return (int64_t)ret_conv;
20236 }
20237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20238         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
20239         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
20240         return ret_conv;
20241 }
20242
20243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20244         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
20245         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20246         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
20247         return (int64_t)ret_conv;
20248 }
20249
20250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
20251         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
20252         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20253         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
20254         return (int64_t)ret_conv;
20255 }
20256
20257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20258         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20259         CHECK_ACCESS(e_ptr);
20260         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20261         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20262         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20263         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
20264         return (int64_t)ret_conv;
20265 }
20266
20267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20268         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
20269         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
20270         return ret_conv;
20271 }
20272
20273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20274         if ((_res & 1) != 0) return;
20275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20276         CHECK_ACCESS(_res_ptr);
20277         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
20278         FREE((void*)_res);
20279         CResult_SiPrefixParseErrorZ_free(_res_conv);
20280 }
20281
20282 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
20283         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20284         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
20285         return (int64_t)ret_conv;
20286 }
20287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20288         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
20289         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
20290         return ret_conv;
20291 }
20292
20293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20294         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
20295         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20296         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
20297         return (int64_t)ret_conv;
20298 }
20299
20300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20301         LDKInvoice o_conv;
20302         o_conv.inner = (void*)(o & (~1));
20303         o_conv.is_owned = (o & 1) || (o == 0);
20304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20305         o_conv = Invoice_clone(&o_conv);
20306         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20307         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
20308         return (int64_t)ret_conv;
20309 }
20310
20311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20312         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20313         CHECK_ACCESS(e_ptr);
20314         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
20315         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
20316         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20317         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
20318         return (int64_t)ret_conv;
20319 }
20320
20321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20322         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
20323         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
20324         return ret_conv;
20325 }
20326
20327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20328         if ((_res & 1) != 0) return;
20329         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20330         CHECK_ACCESS(_res_ptr);
20331         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
20332         FREE((void*)_res);
20333         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
20334 }
20335
20336 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
20337         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20338         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
20339         return (int64_t)ret_conv;
20340 }
20341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20342         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
20343         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
20344         return ret_conv;
20345 }
20346
20347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20348         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
20349         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20350         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
20351         return (int64_t)ret_conv;
20352 }
20353
20354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20355         LDKSignedRawInvoice o_conv;
20356         o_conv.inner = (void*)(o & (~1));
20357         o_conv.is_owned = (o & 1) || (o == 0);
20358         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20359         o_conv = SignedRawInvoice_clone(&o_conv);
20360         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20361         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
20362         return (int64_t)ret_conv;
20363 }
20364
20365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20366         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20367         CHECK_ACCESS(e_ptr);
20368         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20369         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20370         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20371         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
20372         return (int64_t)ret_conv;
20373 }
20374
20375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20376         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
20377         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
20378         return ret_conv;
20379 }
20380
20381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20382         if ((_res & 1) != 0) return;
20383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20384         CHECK_ACCESS(_res_ptr);
20385         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
20386         FREE((void*)_res);
20387         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
20388 }
20389
20390 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
20391         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20392         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
20393         return (int64_t)ret_conv;
20394 }
20395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20396         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
20397         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
20398         return ret_conv;
20399 }
20400
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20402         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
20403         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20404         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
20405         return (int64_t)ret_conv;
20406 }
20407
20408 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
20409         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20410         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
20411         return ((int64_t)ret_conv);
20412 }
20413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20414         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
20415         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
20416         return ret_conv;
20417 }
20418
20419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20420         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
20421         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20422         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
20423         return ((int64_t)ret_conv);
20424 }
20425
20426 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) {
20427         LDKRawInvoice a_conv;
20428         a_conv.inner = (void*)(a & (~1));
20429         a_conv.is_owned = (a & 1) || (a == 0);
20430         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20431         a_conv = RawInvoice_clone(&a_conv);
20432         LDKThirtyTwoBytes b_ref;
20433         CHECK((*env)->GetArrayLength(env, b) == 32);
20434         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20435         LDKInvoiceSignature c_conv;
20436         c_conv.inner = (void*)(c & (~1));
20437         c_conv.is_owned = (c & 1) || (c == 0);
20438         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20439         c_conv = InvoiceSignature_clone(&c_conv);
20440         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20441         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
20442         return ((int64_t)ret_conv);
20443 }
20444
20445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20446         if ((_res & 1) != 0) return;
20447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20448         CHECK_ACCESS(_res_ptr);
20449         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
20450         FREE((void*)_res);
20451         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
20452 }
20453
20454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20455         LDKPayeePubKey o_conv;
20456         o_conv.inner = (void*)(o & (~1));
20457         o_conv.is_owned = (o & 1) || (o == 0);
20458         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20459         o_conv = PayeePubKey_clone(&o_conv);
20460         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20461         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
20462         return (int64_t)ret_conv;
20463 }
20464
20465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20466         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20467         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20468         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
20469         return (int64_t)ret_conv;
20470 }
20471
20472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20473         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
20474         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
20475         return ret_conv;
20476 }
20477
20478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20479         if ((_res & 1) != 0) return;
20480         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20481         CHECK_ACCESS(_res_ptr);
20482         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
20483         FREE((void*)_res);
20484         CResult_PayeePubKeyErrorZ_free(_res_conv);
20485 }
20486
20487 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
20488         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20489         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
20490         return (int64_t)ret_conv;
20491 }
20492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20493         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
20494         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
20495         return ret_conv;
20496 }
20497
20498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20499         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
20500         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20501         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
20502         return (int64_t)ret_conv;
20503 }
20504
20505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20506         LDKCVec_PrivateRouteZ _res_constr;
20507         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20508         if (_res_constr.datalen > 0)
20509                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
20510         else
20511                 _res_constr.data = NULL;
20512         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20513         for (size_t o = 0; o < _res_constr.datalen; o++) {
20514                 int64_t _res_conv_14 = _res_vals[o];
20515                 LDKPrivateRoute _res_conv_14_conv;
20516                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
20517                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
20518                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
20519                 _res_constr.data[o] = _res_conv_14_conv;
20520         }
20521         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20522         CVec_PrivateRouteZ_free(_res_constr);
20523 }
20524
20525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20526         LDKPositiveTimestamp o_conv;
20527         o_conv.inner = (void*)(o & (~1));
20528         o_conv.is_owned = (o & 1) || (o == 0);
20529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20530         o_conv = PositiveTimestamp_clone(&o_conv);
20531         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20532         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
20533         return (int64_t)ret_conv;
20534 }
20535
20536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20537         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20538         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20539         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
20540         return (int64_t)ret_conv;
20541 }
20542
20543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20544         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
20545         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
20546         return ret_conv;
20547 }
20548
20549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20550         if ((_res & 1) != 0) return;
20551         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20552         CHECK_ACCESS(_res_ptr);
20553         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
20554         FREE((void*)_res);
20555         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
20556 }
20557
20558 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
20559         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20560         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
20561         return (int64_t)ret_conv;
20562 }
20563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20564         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
20565         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
20566         return ret_conv;
20567 }
20568
20569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20570         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
20571         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20572         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
20573         return (int64_t)ret_conv;
20574 }
20575
20576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
20577         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20578         *ret_conv = CResult_NoneSemanticErrorZ_ok();
20579         return (int64_t)ret_conv;
20580 }
20581
20582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20583         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
20584         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20585         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
20586         return (int64_t)ret_conv;
20587 }
20588
20589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20590         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
20591         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
20592         return ret_conv;
20593 }
20594
20595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20596         if ((_res & 1) != 0) return;
20597         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20598         CHECK_ACCESS(_res_ptr);
20599         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
20600         FREE((void*)_res);
20601         CResult_NoneSemanticErrorZ_free(_res_conv);
20602 }
20603
20604 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
20605         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20606         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
20607         return (int64_t)ret_conv;
20608 }
20609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20610         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
20611         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
20612         return ret_conv;
20613 }
20614
20615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20616         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
20617         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20618         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
20619         return (int64_t)ret_conv;
20620 }
20621
20622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20623         LDKInvoice o_conv;
20624         o_conv.inner = (void*)(o & (~1));
20625         o_conv.is_owned = (o & 1) || (o == 0);
20626         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20627         o_conv = Invoice_clone(&o_conv);
20628         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20629         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
20630         return (int64_t)ret_conv;
20631 }
20632
20633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20634         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
20635         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20636         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
20637         return (int64_t)ret_conv;
20638 }
20639
20640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20641         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
20642         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
20643         return ret_conv;
20644 }
20645
20646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20647         if ((_res & 1) != 0) return;
20648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20649         CHECK_ACCESS(_res_ptr);
20650         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
20651         FREE((void*)_res);
20652         CResult_InvoiceSemanticErrorZ_free(_res_conv);
20653 }
20654
20655 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
20656         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20657         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
20658         return (int64_t)ret_conv;
20659 }
20660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20661         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
20662         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
20663         return ret_conv;
20664 }
20665
20666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20667         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
20668         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20669         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
20670         return (int64_t)ret_conv;
20671 }
20672
20673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20674         LDKDescription o_conv;
20675         o_conv.inner = (void*)(o & (~1));
20676         o_conv.is_owned = (o & 1) || (o == 0);
20677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20678         o_conv = Description_clone(&o_conv);
20679         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20680         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
20681         return (int64_t)ret_conv;
20682 }
20683
20684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20685         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20686         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20687         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
20688         return (int64_t)ret_conv;
20689 }
20690
20691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20692         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
20693         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
20694         return ret_conv;
20695 }
20696
20697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20698         if ((_res & 1) != 0) return;
20699         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20700         CHECK_ACCESS(_res_ptr);
20701         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
20702         FREE((void*)_res);
20703         CResult_DescriptionCreationErrorZ_free(_res_conv);
20704 }
20705
20706 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
20707         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20708         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
20709         return (int64_t)ret_conv;
20710 }
20711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20712         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
20713         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
20714         return ret_conv;
20715 }
20716
20717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20718         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
20719         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20720         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
20721         return (int64_t)ret_conv;
20722 }
20723
20724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20725         LDKPrivateRoute o_conv;
20726         o_conv.inner = (void*)(o & (~1));
20727         o_conv.is_owned = (o & 1) || (o == 0);
20728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20729         o_conv = PrivateRoute_clone(&o_conv);
20730         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20731         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
20732         return (int64_t)ret_conv;
20733 }
20734
20735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20736         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20737         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20738         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
20739         return (int64_t)ret_conv;
20740 }
20741
20742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20743         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
20744         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
20745         return ret_conv;
20746 }
20747
20748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20749         if ((_res & 1) != 0) return;
20750         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20751         CHECK_ACCESS(_res_ptr);
20752         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
20753         FREE((void*)_res);
20754         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
20755 }
20756
20757 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
20758         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20759         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
20760         return (int64_t)ret_conv;
20761 }
20762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20763         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
20764         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
20765         return ret_conv;
20766 }
20767
20768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20769         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
20770         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20771         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
20772         return (int64_t)ret_conv;
20773 }
20774
20775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
20776         LDKStr o_conv = java_to_owned_str(env, o);
20777         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20778         *ret_conv = CResult_StringErrorZ_ok(o_conv);
20779         return (int64_t)ret_conv;
20780 }
20781
20782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20783         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20784         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20785         *ret_conv = CResult_StringErrorZ_err(e_conv);
20786         return (int64_t)ret_conv;
20787 }
20788
20789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20790         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
20791         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
20792         return ret_conv;
20793 }
20794
20795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20796         if ((_res & 1) != 0) return;
20797         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20798         CHECK_ACCESS(_res_ptr);
20799         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
20800         FREE((void*)_res);
20801         CResult_StringErrorZ_free(_res_conv);
20802 }
20803
20804 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
20805         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20806         *ret_conv = CResult_StringErrorZ_clone(arg);
20807         return (int64_t)ret_conv;
20808 }
20809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20810         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
20811         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
20812         return ret_conv;
20813 }
20814
20815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20816         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
20817         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20818         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
20819         return (int64_t)ret_conv;
20820 }
20821
20822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20823         LDKChannelMonitorUpdate o_conv;
20824         o_conv.inner = (void*)(o & (~1));
20825         o_conv.is_owned = (o & 1) || (o == 0);
20826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20827         o_conv = ChannelMonitorUpdate_clone(&o_conv);
20828         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20829         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
20830         return (int64_t)ret_conv;
20831 }
20832
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20834         LDKDecodeError e_conv;
20835         e_conv.inner = (void*)(e & (~1));
20836         e_conv.is_owned = (e & 1) || (e == 0);
20837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20838         e_conv = DecodeError_clone(&e_conv);
20839         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20840         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
20841         return (int64_t)ret_conv;
20842 }
20843
20844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20845         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
20846         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
20847         return ret_conv;
20848 }
20849
20850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20851         if ((_res & 1) != 0) return;
20852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20853         CHECK_ACCESS(_res_ptr);
20854         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
20855         FREE((void*)_res);
20856         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
20857 }
20858
20859 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
20860         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20861         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
20862         return (int64_t)ret_conv;
20863 }
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20865         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
20866         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
20867         return ret_conv;
20868 }
20869
20870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20871         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
20872         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20873         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
20874         return (int64_t)ret_conv;
20875 }
20876
20877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20878         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20879         CHECK_ACCESS(o_ptr);
20880         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
20881         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
20882         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20883         *ret_copy = COption_MonitorEventZ_some(o_conv);
20884         int64_t ret_ref = (uintptr_t)ret_copy;
20885         return ret_ref;
20886 }
20887
20888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
20889         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20890         *ret_copy = COption_MonitorEventZ_none();
20891         int64_t ret_ref = (uintptr_t)ret_copy;
20892         return ret_ref;
20893 }
20894
20895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20896         if ((_res & 1) != 0) return;
20897         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20898         CHECK_ACCESS(_res_ptr);
20899         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
20900         FREE((void*)_res);
20901         COption_MonitorEventZ_free(_res_conv);
20902 }
20903
20904 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
20905         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20906         *ret_copy = COption_MonitorEventZ_clone(arg);
20907 int64_t ret_ref = (uintptr_t)ret_copy;
20908         return ret_ref;
20909 }
20910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20911         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
20912         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
20913         return ret_conv;
20914 }
20915
20916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20917         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
20918         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20919         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
20920         int64_t ret_ref = (uintptr_t)ret_copy;
20921         return ret_ref;
20922 }
20923
20924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20925         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20926         CHECK_ACCESS(o_ptr);
20927         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
20928         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
20929         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20930         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
20931         return (int64_t)ret_conv;
20932 }
20933
20934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20935         LDKDecodeError e_conv;
20936         e_conv.inner = (void*)(e & (~1));
20937         e_conv.is_owned = (e & 1) || (e == 0);
20938         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20939         e_conv = DecodeError_clone(&e_conv);
20940         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20941         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
20942         return (int64_t)ret_conv;
20943 }
20944
20945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20946         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
20947         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
20948         return ret_conv;
20949 }
20950
20951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20952         if ((_res & 1) != 0) return;
20953         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20954         CHECK_ACCESS(_res_ptr);
20955         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
20956         FREE((void*)_res);
20957         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
20958 }
20959
20960 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
20961         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20962         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
20963         return (int64_t)ret_conv;
20964 }
20965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20966         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
20967         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
20968         return ret_conv;
20969 }
20970
20971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20972         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
20973         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20974         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
20975         return (int64_t)ret_conv;
20976 }
20977
20978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20979         LDKHTLCUpdate o_conv;
20980         o_conv.inner = (void*)(o & (~1));
20981         o_conv.is_owned = (o & 1) || (o == 0);
20982         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20983         o_conv = HTLCUpdate_clone(&o_conv);
20984         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20985         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
20986         return (int64_t)ret_conv;
20987 }
20988
20989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20990         LDKDecodeError e_conv;
20991         e_conv.inner = (void*)(e & (~1));
20992         e_conv.is_owned = (e & 1) || (e == 0);
20993         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20994         e_conv = DecodeError_clone(&e_conv);
20995         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20996         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
20997         return (int64_t)ret_conv;
20998 }
20999
21000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21001         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
21002         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
21003         return ret_conv;
21004 }
21005
21006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21007         if ((_res & 1) != 0) return;
21008         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21009         CHECK_ACCESS(_res_ptr);
21010         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
21011         FREE((void*)_res);
21012         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
21013 }
21014
21015 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
21016         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21017         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
21018         return (int64_t)ret_conv;
21019 }
21020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21021         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
21022         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
21023         return ret_conv;
21024 }
21025
21026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21027         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
21028         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21029         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
21030         return (int64_t)ret_conv;
21031 }
21032
21033 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
21034         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21035         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
21036         return ((int64_t)ret_conv);
21037 }
21038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21039         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
21040         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
21041         return ret_conv;
21042 }
21043
21044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21045         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
21046         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21047         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
21048         return ((int64_t)ret_conv);
21049 }
21050
21051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
21052         LDKOutPoint a_conv;
21053         a_conv.inner = (void*)(a & (~1));
21054         a_conv.is_owned = (a & 1) || (a == 0);
21055         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21056         a_conv = OutPoint_clone(&a_conv);
21057         LDKCVec_u8Z b_ref;
21058         b_ref.datalen = (*env)->GetArrayLength(env, b);
21059         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21060         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21061         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21062         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
21063         return ((int64_t)ret_conv);
21064 }
21065
21066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21067         if ((_res & 1) != 0) return;
21068         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21069         CHECK_ACCESS(_res_ptr);
21070         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
21071         FREE((void*)_res);
21072         C2Tuple_OutPointScriptZ_free(_res_conv);
21073 }
21074
21075 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
21076         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21077         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
21078         return ((int64_t)ret_conv);
21079 }
21080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21081         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
21082         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
21083         return ret_conv;
21084 }
21085
21086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21087         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
21088         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21089         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
21090         return ((int64_t)ret_conv);
21091 }
21092
21093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
21094         LDKCVec_u8Z b_ref;
21095         b_ref.datalen = (*env)->GetArrayLength(env, b);
21096         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21097         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21098         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21099         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
21100         return ((int64_t)ret_conv);
21101 }
21102
21103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21104         if ((_res & 1) != 0) return;
21105         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21106         CHECK_ACCESS(_res_ptr);
21107         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
21108         FREE((void*)_res);
21109         C2Tuple_u32ScriptZ_free(_res_conv);
21110 }
21111
21112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21113         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
21114         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21115         if (_res_constr.datalen > 0)
21116                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21117         else
21118                 _res_constr.data = NULL;
21119         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21120         for (size_t v = 0; v < _res_constr.datalen; v++) {
21121                 int64_t _res_conv_21 = _res_vals[v];
21122                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
21123                 CHECK_ACCESS(_res_conv_21_ptr);
21124                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
21125                 FREE((void*)_res_conv_21);
21126                 _res_constr.data[v] = _res_conv_21_conv;
21127         }
21128         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21129         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
21130 }
21131
21132 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
21133         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21134         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
21135         return ((int64_t)ret_conv);
21136 }
21137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21138         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
21139         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
21140         return ret_conv;
21141 }
21142
21143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21144         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
21145         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21146         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
21147         return ((int64_t)ret_conv);
21148 }
21149
21150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21151         LDKThirtyTwoBytes a_ref;
21152         CHECK((*env)->GetArrayLength(env, a) == 32);
21153         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21154         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
21155         b_constr.datalen = (*env)->GetArrayLength(env, b);
21156         if (b_constr.datalen > 0)
21157                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21158         else
21159                 b_constr.data = NULL;
21160         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21161         for (size_t v = 0; v < b_constr.datalen; v++) {
21162                 int64_t b_conv_21 = b_vals[v];
21163                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
21164                 CHECK_ACCESS(b_conv_21_ptr);
21165                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
21166                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
21167                 b_constr.data[v] = b_conv_21_conv;
21168         }
21169         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21170         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21171         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
21172         return ((int64_t)ret_conv);
21173 }
21174
21175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21176         if ((_res & 1) != 0) return;
21177         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21178         CHECK_ACCESS(_res_ptr);
21179         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
21180         FREE((void*)_res);
21181         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
21182 }
21183
21184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21185         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
21186         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21187         if (_res_constr.datalen > 0)
21188                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
21189         else
21190                 _res_constr.data = NULL;
21191         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21192         for (size_t o = 0; o < _res_constr.datalen; o++) {
21193                 int64_t _res_conv_40 = _res_vals[o];
21194                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
21195                 CHECK_ACCESS(_res_conv_40_ptr);
21196                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
21197                 FREE((void*)_res_conv_40);
21198                 _res_constr.data[o] = _res_conv_40_conv;
21199         }
21200         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21201         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
21202 }
21203
21204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21205         LDKCVec_EventZ _res_constr;
21206         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21207         if (_res_constr.datalen > 0)
21208                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
21209         else
21210                 _res_constr.data = NULL;
21211         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21212         for (size_t h = 0; h < _res_constr.datalen; h++) {
21213                 int64_t _res_conv_7 = _res_vals[h];
21214                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
21215                 CHECK_ACCESS(_res_conv_7_ptr);
21216                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
21217                 FREE((void*)_res_conv_7);
21218                 _res_constr.data[h] = _res_conv_7_conv;
21219         }
21220         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21221         CVec_EventZ_free(_res_constr);
21222 }
21223
21224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21225         LDKCVec_TransactionZ _res_constr;
21226         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21227         if (_res_constr.datalen > 0)
21228                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
21229         else
21230                 _res_constr.data = NULL;
21231         for (size_t i = 0; i < _res_constr.datalen; i++) {
21232                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21233                 LDKTransaction _res_conv_8_ref;
21234                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21235                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
21236                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21237                 _res_conv_8_ref.data_is_owned = true;
21238                 _res_constr.data[i] = _res_conv_8_ref;
21239         }
21240         CVec_TransactionZ_free(_res_constr);
21241 }
21242
21243 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
21244         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21245         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
21246         return ((int64_t)ret_conv);
21247 }
21248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21249         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
21250         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
21251         return ret_conv;
21252 }
21253
21254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21255         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
21256         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21257         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
21258         return ((int64_t)ret_conv);
21259 }
21260
21261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
21262         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21263         CHECK_ACCESS(b_ptr);
21264         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
21265         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
21266         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21267         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
21268         return ((int64_t)ret_conv);
21269 }
21270
21271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21272         if ((_res & 1) != 0) return;
21273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21274         CHECK_ACCESS(_res_ptr);
21275         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
21276         FREE((void*)_res);
21277         C2Tuple_u32TxOutZ_free(_res_conv);
21278 }
21279
21280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21281         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
21282         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21283         if (_res_constr.datalen > 0)
21284                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21285         else
21286                 _res_constr.data = NULL;
21287         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21288         for (size_t u = 0; u < _res_constr.datalen; u++) {
21289                 int64_t _res_conv_20 = _res_vals[u];
21290                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
21291                 CHECK_ACCESS(_res_conv_20_ptr);
21292                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
21293                 FREE((void*)_res_conv_20);
21294                 _res_constr.data[u] = _res_conv_20_conv;
21295         }
21296         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21297         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
21298 }
21299
21300 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
21301         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21302         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
21303         return ((int64_t)ret_conv);
21304 }
21305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21306         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
21307         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
21308         return ret_conv;
21309 }
21310
21311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21312         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
21313         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21314         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
21315         return ((int64_t)ret_conv);
21316 }
21317
21318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21319         LDKThirtyTwoBytes a_ref;
21320         CHECK((*env)->GetArrayLength(env, a) == 32);
21321         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21322         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
21323         b_constr.datalen = (*env)->GetArrayLength(env, b);
21324         if (b_constr.datalen > 0)
21325                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21326         else
21327                 b_constr.data = NULL;
21328         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21329         for (size_t u = 0; u < b_constr.datalen; u++) {
21330                 int64_t b_conv_20 = b_vals[u];
21331                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
21332                 CHECK_ACCESS(b_conv_20_ptr);
21333                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
21334                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
21335                 b_constr.data[u] = b_conv_20_conv;
21336         }
21337         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21338         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21339         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
21340         return ((int64_t)ret_conv);
21341 }
21342
21343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21344         if ((_res & 1) != 0) return;
21345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21346         CHECK_ACCESS(_res_ptr);
21347         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
21348         FREE((void*)_res);
21349         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
21350 }
21351
21352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21353         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
21354         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21355         if (_res_constr.datalen > 0)
21356                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
21357         else
21358                 _res_constr.data = NULL;
21359         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21360         for (size_t n = 0; n < _res_constr.datalen; n++) {
21361                 int64_t _res_conv_39 = _res_vals[n];
21362                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
21363                 CHECK_ACCESS(_res_conv_39_ptr);
21364                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
21365                 FREE((void*)_res_conv_39);
21366                 _res_constr.data[n] = _res_conv_39_conv;
21367         }
21368         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21369         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
21370 }
21371
21372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21373         LDKCVec_BalanceZ _res_constr;
21374         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21375         if (_res_constr.datalen > 0)
21376                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
21377         else
21378                 _res_constr.data = NULL;
21379         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21380         for (size_t j = 0; j < _res_constr.datalen; j++) {
21381                 int64_t _res_conv_9 = _res_vals[j];
21382                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
21383                 CHECK_ACCESS(_res_conv_9_ptr);
21384                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
21385                 FREE((void*)_res_conv_9);
21386                 _res_constr.data[j] = _res_conv_9_conv;
21387         }
21388         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21389         CVec_BalanceZ_free(_res_constr);
21390 }
21391
21392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21393         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21394         CHECK_ACCESS(o_ptr);
21395         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
21396         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
21397         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21398         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
21399         return (int64_t)ret_conv;
21400 }
21401
21402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21403         LDKDecodeError e_conv;
21404         e_conv.inner = (void*)(e & (~1));
21405         e_conv.is_owned = (e & 1) || (e == 0);
21406         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21407         e_conv = DecodeError_clone(&e_conv);
21408         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21409         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
21410         return (int64_t)ret_conv;
21411 }
21412
21413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21414         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
21415         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
21416         return ret_conv;
21417 }
21418
21419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21420         if ((_res & 1) != 0) return;
21421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21422         CHECK_ACCESS(_res_ptr);
21423         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
21424         FREE((void*)_res);
21425         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
21426 }
21427
21428 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
21429         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21430         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
21431         return (int64_t)ret_conv;
21432 }
21433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21434         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
21435         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
21436         return ret_conv;
21437 }
21438
21439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21440         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
21441         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21442         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
21443         return (int64_t)ret_conv;
21444 }
21445
21446 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
21447         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21448         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
21449         return ((int64_t)ret_conv);
21450 }
21451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21452         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
21453         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
21454         return ret_conv;
21455 }
21456
21457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21458         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
21459         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21460         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
21461         return ((int64_t)ret_conv);
21462 }
21463
21464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21465         LDKPublicKey a_ref;
21466         CHECK((*env)->GetArrayLength(env, a) == 33);
21467         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
21468         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21469         CHECK_ACCESS(b_ptr);
21470         LDKType b_conv = *(LDKType*)(b_ptr);
21471         if (b_conv.free == LDKType_JCalls_free) {
21472                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21473                 LDKType_JCalls_cloned(&b_conv);
21474         }
21475         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21476         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
21477         return ((int64_t)ret_conv);
21478 }
21479
21480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21481         if ((_res & 1) != 0) return;
21482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21483         CHECK_ACCESS(_res_ptr);
21484         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
21485         FREE((void*)_res);
21486         C2Tuple_PublicKeyTypeZ_free(_res_conv);
21487 }
21488
21489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21490         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
21491         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21492         if (_res_constr.datalen > 0)
21493                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
21494         else
21495                 _res_constr.data = NULL;
21496         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21497         for (size_t z = 0; z < _res_constr.datalen; z++) {
21498                 int64_t _res_conv_25 = _res_vals[z];
21499                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
21500                 CHECK_ACCESS(_res_conv_25_ptr);
21501                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
21502                 FREE((void*)_res_conv_25);
21503                 _res_constr.data[z] = _res_conv_25_conv;
21504         }
21505         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21506         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
21507 }
21508
21509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21510         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21511         CHECK_ACCESS(o_ptr);
21512         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21513         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21514         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21515         *ret_copy = COption_NetAddressZ_some(o_conv);
21516         int64_t ret_ref = (uintptr_t)ret_copy;
21517         return ret_ref;
21518 }
21519
21520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
21521         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21522         *ret_copy = COption_NetAddressZ_none();
21523         int64_t ret_ref = (uintptr_t)ret_copy;
21524         return ret_ref;
21525 }
21526
21527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21528         if ((_res & 1) != 0) return;
21529         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21530         CHECK_ACCESS(_res_ptr);
21531         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
21532         FREE((void*)_res);
21533         COption_NetAddressZ_free(_res_conv);
21534 }
21535
21536 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
21537         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21538         *ret_copy = COption_NetAddressZ_clone(arg);
21539 int64_t ret_ref = (uintptr_t)ret_copy;
21540         return ret_ref;
21541 }
21542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21543         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
21544         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
21545         return ret_conv;
21546 }
21547
21548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21549         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
21550         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21551         *ret_copy = COption_NetAddressZ_clone(orig_conv);
21552         int64_t ret_ref = (uintptr_t)ret_copy;
21553         return ret_ref;
21554 }
21555
21556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21557         LDKCVec_u8Z o_ref;
21558         o_ref.datalen = (*env)->GetArrayLength(env, o);
21559         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
21560         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21561         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21562         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
21563         return (int64_t)ret_conv;
21564 }
21565
21566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21567         LDKPeerHandleError e_conv;
21568         e_conv.inner = (void*)(e & (~1));
21569         e_conv.is_owned = (e & 1) || (e == 0);
21570         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21571         e_conv = PeerHandleError_clone(&e_conv);
21572         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21573         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
21574         return (int64_t)ret_conv;
21575 }
21576
21577 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21578         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
21579         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
21580         return ret_conv;
21581 }
21582
21583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21584         if ((_res & 1) != 0) return;
21585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21586         CHECK_ACCESS(_res_ptr);
21587         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
21588         FREE((void*)_res);
21589         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
21590 }
21591
21592 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
21593         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21594         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
21595         return (int64_t)ret_conv;
21596 }
21597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21598         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
21599         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
21600         return ret_conv;
21601 }
21602
21603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21604         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
21605         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21606         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
21607         return (int64_t)ret_conv;
21608 }
21609
21610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
21611         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21612         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
21613         return (int64_t)ret_conv;
21614 }
21615
21616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21617         LDKPeerHandleError e_conv;
21618         e_conv.inner = (void*)(e & (~1));
21619         e_conv.is_owned = (e & 1) || (e == 0);
21620         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21621         e_conv = PeerHandleError_clone(&e_conv);
21622         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21623         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
21624         return (int64_t)ret_conv;
21625 }
21626
21627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21628         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
21629         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
21630         return ret_conv;
21631 }
21632
21633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21634         if ((_res & 1) != 0) return;
21635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21636         CHECK_ACCESS(_res_ptr);
21637         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
21638         FREE((void*)_res);
21639         CResult_NonePeerHandleErrorZ_free(_res_conv);
21640 }
21641
21642 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
21643         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21644         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
21645         return (int64_t)ret_conv;
21646 }
21647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21648         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
21649         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
21650         return ret_conv;
21651 }
21652
21653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21654         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
21655         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21656         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
21657         return (int64_t)ret_conv;
21658 }
21659
21660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
21661         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21662         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
21663         return (int64_t)ret_conv;
21664 }
21665
21666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21667         LDKPeerHandleError e_conv;
21668         e_conv.inner = (void*)(e & (~1));
21669         e_conv.is_owned = (e & 1) || (e == 0);
21670         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21671         e_conv = PeerHandleError_clone(&e_conv);
21672         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21673         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
21674         return (int64_t)ret_conv;
21675 }
21676
21677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21678         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
21679         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
21680         return ret_conv;
21681 }
21682
21683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21684         if ((_res & 1) != 0) return;
21685         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21686         CHECK_ACCESS(_res_ptr);
21687         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
21688         FREE((void*)_res);
21689         CResult_boolPeerHandleErrorZ_free(_res_conv);
21690 }
21691
21692 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
21693         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21694         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
21695         return (int64_t)ret_conv;
21696 }
21697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21698         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
21699         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
21700         return ret_conv;
21701 }
21702
21703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21704         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
21705         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21706         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
21707         return (int64_t)ret_conv;
21708 }
21709
21710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
21711         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
21712         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
21713         return (int64_t)ret_conv;
21714 }
21715
21716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21717         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
21718         CHECK_ACCESS(e_ptr);
21719         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
21720         e_conv = GraphSyncError_clone((LDKGraphSyncError*)(((uintptr_t)e) & ~1));
21721         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
21722         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
21723         return (int64_t)ret_conv;
21724 }
21725
21726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21727         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)(o & ~1);
21728         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
21729         return ret_conv;
21730 }
21731
21732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21733         if ((_res & 1) != 0) return;
21734         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21735         CHECK_ACCESS(_res_ptr);
21736         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
21737         FREE((void*)_res);
21738         CResult_u32GraphSyncErrorZ_free(_res_conv);
21739 }
21740
21741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21742         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21743         CHECK_ACCESS(o_ptr);
21744         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21745         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21746         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21747         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
21748         return (int64_t)ret_conv;
21749 }
21750
21751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21752         LDKDecodeError e_conv;
21753         e_conv.inner = (void*)(e & (~1));
21754         e_conv.is_owned = (e & 1) || (e == 0);
21755         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21756         e_conv = DecodeError_clone(&e_conv);
21757         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21758         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
21759         return (int64_t)ret_conv;
21760 }
21761
21762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21763         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
21764         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
21765         return ret_conv;
21766 }
21767
21768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21769         if ((_res & 1) != 0) return;
21770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21771         CHECK_ACCESS(_res_ptr);
21772         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
21773         FREE((void*)_res);
21774         CResult_NetAddressDecodeErrorZ_free(_res_conv);
21775 }
21776
21777 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
21778         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21779         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
21780         return (int64_t)ret_conv;
21781 }
21782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21783         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
21784         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
21785         return ret_conv;
21786 }
21787
21788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21789         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
21790         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21791         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
21792         return (int64_t)ret_conv;
21793 }
21794
21795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21796         LDKCVec_UpdateAddHTLCZ _res_constr;
21797         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21798         if (_res_constr.datalen > 0)
21799                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21800         else
21801                 _res_constr.data = NULL;
21802         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21803         for (size_t p = 0; p < _res_constr.datalen; p++) {
21804                 int64_t _res_conv_15 = _res_vals[p];
21805                 LDKUpdateAddHTLC _res_conv_15_conv;
21806                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
21807                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
21808                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
21809                 _res_constr.data[p] = _res_conv_15_conv;
21810         }
21811         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21812         CVec_UpdateAddHTLCZ_free(_res_constr);
21813 }
21814
21815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21816         LDKCVec_UpdateFulfillHTLCZ _res_constr;
21817         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21818         if (_res_constr.datalen > 0)
21819                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21820         else
21821                 _res_constr.data = NULL;
21822         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21823         for (size_t t = 0; t < _res_constr.datalen; t++) {
21824                 int64_t _res_conv_19 = _res_vals[t];
21825                 LDKUpdateFulfillHTLC _res_conv_19_conv;
21826                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
21827                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
21828                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
21829                 _res_constr.data[t] = _res_conv_19_conv;
21830         }
21831         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21832         CVec_UpdateFulfillHTLCZ_free(_res_constr);
21833 }
21834
21835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21836         LDKCVec_UpdateFailHTLCZ _res_constr;
21837         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21838         if (_res_constr.datalen > 0)
21839                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21840         else
21841                 _res_constr.data = NULL;
21842         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21843         for (size_t q = 0; q < _res_constr.datalen; q++) {
21844                 int64_t _res_conv_16 = _res_vals[q];
21845                 LDKUpdateFailHTLC _res_conv_16_conv;
21846                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
21847                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
21848                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21849                 _res_constr.data[q] = _res_conv_16_conv;
21850         }
21851         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21852         CVec_UpdateFailHTLCZ_free(_res_constr);
21853 }
21854
21855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21856         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21857         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21858         if (_res_constr.datalen > 0)
21859                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21860         else
21861                 _res_constr.data = NULL;
21862         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21863         for (size_t z = 0; z < _res_constr.datalen; z++) {
21864                 int64_t _res_conv_25 = _res_vals[z];
21865                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21866                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
21867                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
21868                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21869                 _res_constr.data[z] = _res_conv_25_conv;
21870         }
21871         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21872         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21873 }
21874
21875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21876         LDKAcceptChannel o_conv;
21877         o_conv.inner = (void*)(o & (~1));
21878         o_conv.is_owned = (o & 1) || (o == 0);
21879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21880         o_conv = AcceptChannel_clone(&o_conv);
21881         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21882         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21883         return (int64_t)ret_conv;
21884 }
21885
21886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21887         LDKDecodeError e_conv;
21888         e_conv.inner = (void*)(e & (~1));
21889         e_conv.is_owned = (e & 1) || (e == 0);
21890         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21891         e_conv = DecodeError_clone(&e_conv);
21892         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21893         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21894         return (int64_t)ret_conv;
21895 }
21896
21897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21898         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
21899         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21900         return ret_conv;
21901 }
21902
21903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21904         if ((_res & 1) != 0) return;
21905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21906         CHECK_ACCESS(_res_ptr);
21907         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21908         FREE((void*)_res);
21909         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21910 }
21911
21912 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21913         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21914         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21915         return (int64_t)ret_conv;
21916 }
21917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21918         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
21919         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21920         return ret_conv;
21921 }
21922
21923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21924         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
21925         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21926         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21927         return (int64_t)ret_conv;
21928 }
21929
21930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21931         LDKAnnouncementSignatures o_conv;
21932         o_conv.inner = (void*)(o & (~1));
21933         o_conv.is_owned = (o & 1) || (o == 0);
21934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21935         o_conv = AnnouncementSignatures_clone(&o_conv);
21936         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21937         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21938         return (int64_t)ret_conv;
21939 }
21940
21941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21942         LDKDecodeError e_conv;
21943         e_conv.inner = (void*)(e & (~1));
21944         e_conv.is_owned = (e & 1) || (e == 0);
21945         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21946         e_conv = DecodeError_clone(&e_conv);
21947         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21948         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21949         return (int64_t)ret_conv;
21950 }
21951
21952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21953         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
21954         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21955         return ret_conv;
21956 }
21957
21958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21959         if ((_res & 1) != 0) return;
21960         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21961         CHECK_ACCESS(_res_ptr);
21962         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21963         FREE((void*)_res);
21964         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21965 }
21966
21967 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21968         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21969         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21970         return (int64_t)ret_conv;
21971 }
21972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21973         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
21974         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21975         return ret_conv;
21976 }
21977
21978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21979         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
21980         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21981         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21982         return (int64_t)ret_conv;
21983 }
21984
21985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21986         LDKChannelReestablish o_conv;
21987         o_conv.inner = (void*)(o & (~1));
21988         o_conv.is_owned = (o & 1) || (o == 0);
21989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21990         o_conv = ChannelReestablish_clone(&o_conv);
21991         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21992         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21993         return (int64_t)ret_conv;
21994 }
21995
21996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21997         LDKDecodeError e_conv;
21998         e_conv.inner = (void*)(e & (~1));
21999         e_conv.is_owned = (e & 1) || (e == 0);
22000         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22001         e_conv = DecodeError_clone(&e_conv);
22002         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22003         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
22004         return (int64_t)ret_conv;
22005 }
22006
22007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22008         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
22009         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
22010         return ret_conv;
22011 }
22012
22013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22014         if ((_res & 1) != 0) return;
22015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22016         CHECK_ACCESS(_res_ptr);
22017         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
22018         FREE((void*)_res);
22019         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
22020 }
22021
22022 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
22023         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22024         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
22025         return (int64_t)ret_conv;
22026 }
22027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22028         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
22029         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
22030         return ret_conv;
22031 }
22032
22033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22034         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
22035         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22036         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
22037         return (int64_t)ret_conv;
22038 }
22039
22040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22041         LDKClosingSigned o_conv;
22042         o_conv.inner = (void*)(o & (~1));
22043         o_conv.is_owned = (o & 1) || (o == 0);
22044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22045         o_conv = ClosingSigned_clone(&o_conv);
22046         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22047         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
22048         return (int64_t)ret_conv;
22049 }
22050
22051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22052         LDKDecodeError e_conv;
22053         e_conv.inner = (void*)(e & (~1));
22054         e_conv.is_owned = (e & 1) || (e == 0);
22055         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22056         e_conv = DecodeError_clone(&e_conv);
22057         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22058         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
22059         return (int64_t)ret_conv;
22060 }
22061
22062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22063         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
22064         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
22065         return ret_conv;
22066 }
22067
22068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22069         if ((_res & 1) != 0) return;
22070         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22071         CHECK_ACCESS(_res_ptr);
22072         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
22073         FREE((void*)_res);
22074         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
22075 }
22076
22077 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
22078         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22079         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
22080         return (int64_t)ret_conv;
22081 }
22082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22083         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
22084         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
22085         return ret_conv;
22086 }
22087
22088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22089         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
22090         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22091         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
22092         return (int64_t)ret_conv;
22093 }
22094
22095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22096         LDKClosingSignedFeeRange o_conv;
22097         o_conv.inner = (void*)(o & (~1));
22098         o_conv.is_owned = (o & 1) || (o == 0);
22099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22100         o_conv = ClosingSignedFeeRange_clone(&o_conv);
22101         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22102         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
22103         return (int64_t)ret_conv;
22104 }
22105
22106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22107         LDKDecodeError e_conv;
22108         e_conv.inner = (void*)(e & (~1));
22109         e_conv.is_owned = (e & 1) || (e == 0);
22110         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22111         e_conv = DecodeError_clone(&e_conv);
22112         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22113         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
22114         return (int64_t)ret_conv;
22115 }
22116
22117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22118         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
22119         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
22120         return ret_conv;
22121 }
22122
22123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22124         if ((_res & 1) != 0) return;
22125         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22126         CHECK_ACCESS(_res_ptr);
22127         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
22128         FREE((void*)_res);
22129         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
22130 }
22131
22132 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
22133         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22134         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
22135         return (int64_t)ret_conv;
22136 }
22137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22138         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
22139         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
22140         return ret_conv;
22141 }
22142
22143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22144         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
22145         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22146         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
22147         return (int64_t)ret_conv;
22148 }
22149
22150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22151         LDKCommitmentSigned o_conv;
22152         o_conv.inner = (void*)(o & (~1));
22153         o_conv.is_owned = (o & 1) || (o == 0);
22154         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22155         o_conv = CommitmentSigned_clone(&o_conv);
22156         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22157         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
22158         return (int64_t)ret_conv;
22159 }
22160
22161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22162         LDKDecodeError e_conv;
22163         e_conv.inner = (void*)(e & (~1));
22164         e_conv.is_owned = (e & 1) || (e == 0);
22165         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22166         e_conv = DecodeError_clone(&e_conv);
22167         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22168         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
22169         return (int64_t)ret_conv;
22170 }
22171
22172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22173         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
22174         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
22175         return ret_conv;
22176 }
22177
22178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22179         if ((_res & 1) != 0) return;
22180         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22181         CHECK_ACCESS(_res_ptr);
22182         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
22183         FREE((void*)_res);
22184         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
22185 }
22186
22187 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
22188         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22189         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
22190         return (int64_t)ret_conv;
22191 }
22192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22193         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
22194         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
22195         return ret_conv;
22196 }
22197
22198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22199         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
22200         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22201         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
22202         return (int64_t)ret_conv;
22203 }
22204
22205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22206         LDKFundingCreated o_conv;
22207         o_conv.inner = (void*)(o & (~1));
22208         o_conv.is_owned = (o & 1) || (o == 0);
22209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22210         o_conv = FundingCreated_clone(&o_conv);
22211         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22212         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
22213         return (int64_t)ret_conv;
22214 }
22215
22216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22217         LDKDecodeError e_conv;
22218         e_conv.inner = (void*)(e & (~1));
22219         e_conv.is_owned = (e & 1) || (e == 0);
22220         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22221         e_conv = DecodeError_clone(&e_conv);
22222         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22223         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
22224         return (int64_t)ret_conv;
22225 }
22226
22227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22228         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
22229         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
22230         return ret_conv;
22231 }
22232
22233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22234         if ((_res & 1) != 0) return;
22235         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22236         CHECK_ACCESS(_res_ptr);
22237         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
22238         FREE((void*)_res);
22239         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
22240 }
22241
22242 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
22243         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22244         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
22245         return (int64_t)ret_conv;
22246 }
22247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22248         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
22249         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
22250         return ret_conv;
22251 }
22252
22253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22254         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
22255         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22256         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
22257         return (int64_t)ret_conv;
22258 }
22259
22260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22261         LDKFundingSigned o_conv;
22262         o_conv.inner = (void*)(o & (~1));
22263         o_conv.is_owned = (o & 1) || (o == 0);
22264         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22265         o_conv = FundingSigned_clone(&o_conv);
22266         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22267         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
22268         return (int64_t)ret_conv;
22269 }
22270
22271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22272         LDKDecodeError e_conv;
22273         e_conv.inner = (void*)(e & (~1));
22274         e_conv.is_owned = (e & 1) || (e == 0);
22275         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22276         e_conv = DecodeError_clone(&e_conv);
22277         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22278         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
22279         return (int64_t)ret_conv;
22280 }
22281
22282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22283         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
22284         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
22285         return ret_conv;
22286 }
22287
22288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22289         if ((_res & 1) != 0) return;
22290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22291         CHECK_ACCESS(_res_ptr);
22292         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
22293         FREE((void*)_res);
22294         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
22295 }
22296
22297 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
22298         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22299         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
22300         return (int64_t)ret_conv;
22301 }
22302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22303         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
22304         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
22305         return ret_conv;
22306 }
22307
22308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22309         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
22310         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22311         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
22312         return (int64_t)ret_conv;
22313 }
22314
22315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22316         LDKChannelReady o_conv;
22317         o_conv.inner = (void*)(o & (~1));
22318         o_conv.is_owned = (o & 1) || (o == 0);
22319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22320         o_conv = ChannelReady_clone(&o_conv);
22321         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22322         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
22323         return (int64_t)ret_conv;
22324 }
22325
22326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22327         LDKDecodeError e_conv;
22328         e_conv.inner = (void*)(e & (~1));
22329         e_conv.is_owned = (e & 1) || (e == 0);
22330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22331         e_conv = DecodeError_clone(&e_conv);
22332         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22333         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
22334         return (int64_t)ret_conv;
22335 }
22336
22337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22338         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
22339         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
22340         return ret_conv;
22341 }
22342
22343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22344         if ((_res & 1) != 0) return;
22345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22346         CHECK_ACCESS(_res_ptr);
22347         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
22348         FREE((void*)_res);
22349         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
22350 }
22351
22352 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
22353         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22354         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
22355         return (int64_t)ret_conv;
22356 }
22357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22358         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
22359         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
22360         return ret_conv;
22361 }
22362
22363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22364         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
22365         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22366         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
22367         return (int64_t)ret_conv;
22368 }
22369
22370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22371         LDKInit o_conv;
22372         o_conv.inner = (void*)(o & (~1));
22373         o_conv.is_owned = (o & 1) || (o == 0);
22374         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22375         o_conv = Init_clone(&o_conv);
22376         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22377         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
22378         return (int64_t)ret_conv;
22379 }
22380
22381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22382         LDKDecodeError e_conv;
22383         e_conv.inner = (void*)(e & (~1));
22384         e_conv.is_owned = (e & 1) || (e == 0);
22385         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22386         e_conv = DecodeError_clone(&e_conv);
22387         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22388         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
22389         return (int64_t)ret_conv;
22390 }
22391
22392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22393         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
22394         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
22395         return ret_conv;
22396 }
22397
22398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22399         if ((_res & 1) != 0) return;
22400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22401         CHECK_ACCESS(_res_ptr);
22402         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
22403         FREE((void*)_res);
22404         CResult_InitDecodeErrorZ_free(_res_conv);
22405 }
22406
22407 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
22408         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22409         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
22410         return (int64_t)ret_conv;
22411 }
22412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22413         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
22414         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
22415         return ret_conv;
22416 }
22417
22418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22419         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
22420         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22421         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
22422         return (int64_t)ret_conv;
22423 }
22424
22425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22426         LDKOpenChannel o_conv;
22427         o_conv.inner = (void*)(o & (~1));
22428         o_conv.is_owned = (o & 1) || (o == 0);
22429         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22430         o_conv = OpenChannel_clone(&o_conv);
22431         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22432         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
22433         return (int64_t)ret_conv;
22434 }
22435
22436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22437         LDKDecodeError e_conv;
22438         e_conv.inner = (void*)(e & (~1));
22439         e_conv.is_owned = (e & 1) || (e == 0);
22440         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22441         e_conv = DecodeError_clone(&e_conv);
22442         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22443         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
22444         return (int64_t)ret_conv;
22445 }
22446
22447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22448         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
22449         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
22450         return ret_conv;
22451 }
22452
22453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22454         if ((_res & 1) != 0) return;
22455         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22456         CHECK_ACCESS(_res_ptr);
22457         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
22458         FREE((void*)_res);
22459         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
22460 }
22461
22462 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
22463         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22464         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
22465         return (int64_t)ret_conv;
22466 }
22467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22468         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
22469         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
22470         return ret_conv;
22471 }
22472
22473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22474         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
22475         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22476         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
22477         return (int64_t)ret_conv;
22478 }
22479
22480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22481         LDKRevokeAndACK o_conv;
22482         o_conv.inner = (void*)(o & (~1));
22483         o_conv.is_owned = (o & 1) || (o == 0);
22484         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22485         o_conv = RevokeAndACK_clone(&o_conv);
22486         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22487         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
22488         return (int64_t)ret_conv;
22489 }
22490
22491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22492         LDKDecodeError e_conv;
22493         e_conv.inner = (void*)(e & (~1));
22494         e_conv.is_owned = (e & 1) || (e == 0);
22495         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22496         e_conv = DecodeError_clone(&e_conv);
22497         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22498         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
22499         return (int64_t)ret_conv;
22500 }
22501
22502 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22503         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
22504         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
22505         return ret_conv;
22506 }
22507
22508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22509         if ((_res & 1) != 0) return;
22510         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22511         CHECK_ACCESS(_res_ptr);
22512         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
22513         FREE((void*)_res);
22514         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
22515 }
22516
22517 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
22518         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22519         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
22520         return (int64_t)ret_conv;
22521 }
22522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22523         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
22524         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
22525         return ret_conv;
22526 }
22527
22528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22529         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
22530         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22531         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
22532         return (int64_t)ret_conv;
22533 }
22534
22535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22536         LDKShutdown o_conv;
22537         o_conv.inner = (void*)(o & (~1));
22538         o_conv.is_owned = (o & 1) || (o == 0);
22539         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22540         o_conv = Shutdown_clone(&o_conv);
22541         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22542         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
22543         return (int64_t)ret_conv;
22544 }
22545
22546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22547         LDKDecodeError e_conv;
22548         e_conv.inner = (void*)(e & (~1));
22549         e_conv.is_owned = (e & 1) || (e == 0);
22550         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22551         e_conv = DecodeError_clone(&e_conv);
22552         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22553         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
22554         return (int64_t)ret_conv;
22555 }
22556
22557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22558         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
22559         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
22560         return ret_conv;
22561 }
22562
22563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22564         if ((_res & 1) != 0) return;
22565         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22566         CHECK_ACCESS(_res_ptr);
22567         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
22568         FREE((void*)_res);
22569         CResult_ShutdownDecodeErrorZ_free(_res_conv);
22570 }
22571
22572 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
22573         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22574         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
22575         return (int64_t)ret_conv;
22576 }
22577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22578         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
22579         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
22580         return ret_conv;
22581 }
22582
22583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22584         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
22585         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22586         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
22587         return (int64_t)ret_conv;
22588 }
22589
22590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22591         LDKUpdateFailHTLC o_conv;
22592         o_conv.inner = (void*)(o & (~1));
22593         o_conv.is_owned = (o & 1) || (o == 0);
22594         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22595         o_conv = UpdateFailHTLC_clone(&o_conv);
22596         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22597         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
22598         return (int64_t)ret_conv;
22599 }
22600
22601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22602         LDKDecodeError e_conv;
22603         e_conv.inner = (void*)(e & (~1));
22604         e_conv.is_owned = (e & 1) || (e == 0);
22605         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22606         e_conv = DecodeError_clone(&e_conv);
22607         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22608         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
22609         return (int64_t)ret_conv;
22610 }
22611
22612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22613         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
22614         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
22615         return ret_conv;
22616 }
22617
22618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22619         if ((_res & 1) != 0) return;
22620         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22621         CHECK_ACCESS(_res_ptr);
22622         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
22623         FREE((void*)_res);
22624         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
22625 }
22626
22627 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
22628         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22629         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
22630         return (int64_t)ret_conv;
22631 }
22632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22633         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
22634         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
22635         return ret_conv;
22636 }
22637
22638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22639         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
22640         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22641         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
22642         return (int64_t)ret_conv;
22643 }
22644
22645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22646         LDKUpdateFailMalformedHTLC o_conv;
22647         o_conv.inner = (void*)(o & (~1));
22648         o_conv.is_owned = (o & 1) || (o == 0);
22649         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22650         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
22651         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22652         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
22653         return (int64_t)ret_conv;
22654 }
22655
22656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22657         LDKDecodeError e_conv;
22658         e_conv.inner = (void*)(e & (~1));
22659         e_conv.is_owned = (e & 1) || (e == 0);
22660         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22661         e_conv = DecodeError_clone(&e_conv);
22662         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22663         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
22664         return (int64_t)ret_conv;
22665 }
22666
22667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22668         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
22669         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
22670         return ret_conv;
22671 }
22672
22673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22674         if ((_res & 1) != 0) return;
22675         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22676         CHECK_ACCESS(_res_ptr);
22677         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
22678         FREE((void*)_res);
22679         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
22680 }
22681
22682 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
22683         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22684         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
22685         return (int64_t)ret_conv;
22686 }
22687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22688         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
22689         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
22690         return ret_conv;
22691 }
22692
22693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22694         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
22695         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22696         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
22697         return (int64_t)ret_conv;
22698 }
22699
22700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22701         LDKUpdateFee o_conv;
22702         o_conv.inner = (void*)(o & (~1));
22703         o_conv.is_owned = (o & 1) || (o == 0);
22704         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22705         o_conv = UpdateFee_clone(&o_conv);
22706         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22707         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
22708         return (int64_t)ret_conv;
22709 }
22710
22711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22712         LDKDecodeError e_conv;
22713         e_conv.inner = (void*)(e & (~1));
22714         e_conv.is_owned = (e & 1) || (e == 0);
22715         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22716         e_conv = DecodeError_clone(&e_conv);
22717         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22718         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
22719         return (int64_t)ret_conv;
22720 }
22721
22722 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22723         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
22724         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
22725         return ret_conv;
22726 }
22727
22728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22729         if ((_res & 1) != 0) return;
22730         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22731         CHECK_ACCESS(_res_ptr);
22732         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
22733         FREE((void*)_res);
22734         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
22735 }
22736
22737 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
22738         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22739         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
22740         return (int64_t)ret_conv;
22741 }
22742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22743         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
22744         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
22745         return ret_conv;
22746 }
22747
22748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22749         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
22750         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22751         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
22752         return (int64_t)ret_conv;
22753 }
22754
22755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22756         LDKUpdateFulfillHTLC o_conv;
22757         o_conv.inner = (void*)(o & (~1));
22758         o_conv.is_owned = (o & 1) || (o == 0);
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22760         o_conv = UpdateFulfillHTLC_clone(&o_conv);
22761         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22762         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
22763         return (int64_t)ret_conv;
22764 }
22765
22766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22767         LDKDecodeError e_conv;
22768         e_conv.inner = (void*)(e & (~1));
22769         e_conv.is_owned = (e & 1) || (e == 0);
22770         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22771         e_conv = DecodeError_clone(&e_conv);
22772         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22773         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
22774         return (int64_t)ret_conv;
22775 }
22776
22777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22778         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
22779         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
22780         return ret_conv;
22781 }
22782
22783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22784         if ((_res & 1) != 0) return;
22785         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22786         CHECK_ACCESS(_res_ptr);
22787         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
22788         FREE((void*)_res);
22789         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
22790 }
22791
22792 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
22793         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22794         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
22795         return (int64_t)ret_conv;
22796 }
22797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22798         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
22799         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
22800         return ret_conv;
22801 }
22802
22803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22804         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
22805         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22806         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
22807         return (int64_t)ret_conv;
22808 }
22809
22810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22811         LDKUpdateAddHTLC o_conv;
22812         o_conv.inner = (void*)(o & (~1));
22813         o_conv.is_owned = (o & 1) || (o == 0);
22814         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22815         o_conv = UpdateAddHTLC_clone(&o_conv);
22816         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22817         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
22818         return (int64_t)ret_conv;
22819 }
22820
22821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22822         LDKDecodeError e_conv;
22823         e_conv.inner = (void*)(e & (~1));
22824         e_conv.is_owned = (e & 1) || (e == 0);
22825         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22826         e_conv = DecodeError_clone(&e_conv);
22827         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22828         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
22829         return (int64_t)ret_conv;
22830 }
22831
22832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22833         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
22834         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
22835         return ret_conv;
22836 }
22837
22838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22839         if ((_res & 1) != 0) return;
22840         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22841         CHECK_ACCESS(_res_ptr);
22842         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
22843         FREE((void*)_res);
22844         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
22845 }
22846
22847 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
22848         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22849         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
22850         return (int64_t)ret_conv;
22851 }
22852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22853         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
22854         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22855         return ret_conv;
22856 }
22857
22858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22859         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
22860         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22861         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22862         return (int64_t)ret_conv;
22863 }
22864
22865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22866         LDKPing o_conv;
22867         o_conv.inner = (void*)(o & (~1));
22868         o_conv.is_owned = (o & 1) || (o == 0);
22869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22870         o_conv = Ping_clone(&o_conv);
22871         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22872         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22873         return (int64_t)ret_conv;
22874 }
22875
22876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22877         LDKDecodeError e_conv;
22878         e_conv.inner = (void*)(e & (~1));
22879         e_conv.is_owned = (e & 1) || (e == 0);
22880         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22881         e_conv = DecodeError_clone(&e_conv);
22882         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22883         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22884         return (int64_t)ret_conv;
22885 }
22886
22887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22888         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
22889         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
22890         return ret_conv;
22891 }
22892
22893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22894         if ((_res & 1) != 0) return;
22895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22896         CHECK_ACCESS(_res_ptr);
22897         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22898         FREE((void*)_res);
22899         CResult_PingDecodeErrorZ_free(_res_conv);
22900 }
22901
22902 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22903         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22904         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22905         return (int64_t)ret_conv;
22906 }
22907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22908         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
22909         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22910         return ret_conv;
22911 }
22912
22913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22914         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
22915         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22916         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22917         return (int64_t)ret_conv;
22918 }
22919
22920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22921         LDKPong o_conv;
22922         o_conv.inner = (void*)(o & (~1));
22923         o_conv.is_owned = (o & 1) || (o == 0);
22924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22925         o_conv = Pong_clone(&o_conv);
22926         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22927         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22928         return (int64_t)ret_conv;
22929 }
22930
22931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22932         LDKDecodeError e_conv;
22933         e_conv.inner = (void*)(e & (~1));
22934         e_conv.is_owned = (e & 1) || (e == 0);
22935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22936         e_conv = DecodeError_clone(&e_conv);
22937         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22938         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22939         return (int64_t)ret_conv;
22940 }
22941
22942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22943         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
22944         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
22945         return ret_conv;
22946 }
22947
22948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22949         if ((_res & 1) != 0) return;
22950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22951         CHECK_ACCESS(_res_ptr);
22952         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22953         FREE((void*)_res);
22954         CResult_PongDecodeErrorZ_free(_res_conv);
22955 }
22956
22957 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22958         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22959         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22960         return (int64_t)ret_conv;
22961 }
22962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22963         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
22964         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22965         return ret_conv;
22966 }
22967
22968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22969         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
22970         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22971         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22972         return (int64_t)ret_conv;
22973 }
22974
22975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22976         LDKUnsignedChannelAnnouncement o_conv;
22977         o_conv.inner = (void*)(o & (~1));
22978         o_conv.is_owned = (o & 1) || (o == 0);
22979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22980         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22981         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22982         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22983         return (int64_t)ret_conv;
22984 }
22985
22986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22987         LDKDecodeError e_conv;
22988         e_conv.inner = (void*)(e & (~1));
22989         e_conv.is_owned = (e & 1) || (e == 0);
22990         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22991         e_conv = DecodeError_clone(&e_conv);
22992         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22993         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22994         return (int64_t)ret_conv;
22995 }
22996
22997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22998         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
22999         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23000         return ret_conv;
23001 }
23002
23003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23004         if ((_res & 1) != 0) return;
23005         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23006         CHECK_ACCESS(_res_ptr);
23007         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23008         FREE((void*)_res);
23009         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
23010 }
23011
23012 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23013         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23014         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
23015         return (int64_t)ret_conv;
23016 }
23017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23018         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23019         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23020         return ret_conv;
23021 }
23022
23023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23024         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23025         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23026         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23027         return (int64_t)ret_conv;
23028 }
23029
23030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23031         LDKChannelAnnouncement o_conv;
23032         o_conv.inner = (void*)(o & (~1));
23033         o_conv.is_owned = (o & 1) || (o == 0);
23034         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23035         o_conv = ChannelAnnouncement_clone(&o_conv);
23036         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23037         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
23038         return (int64_t)ret_conv;
23039 }
23040
23041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23042         LDKDecodeError e_conv;
23043         e_conv.inner = (void*)(e & (~1));
23044         e_conv.is_owned = (e & 1) || (e == 0);
23045         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23046         e_conv = DecodeError_clone(&e_conv);
23047         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23048         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
23049         return (int64_t)ret_conv;
23050 }
23051
23052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23053         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
23054         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23055         return ret_conv;
23056 }
23057
23058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23059         if ((_res & 1) != 0) return;
23060         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23061         CHECK_ACCESS(_res_ptr);
23062         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23063         FREE((void*)_res);
23064         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
23065 }
23066
23067 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23068         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23069         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
23070         return (int64_t)ret_conv;
23071 }
23072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23073         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23074         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23075         return ret_conv;
23076 }
23077
23078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23079         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23080         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23081         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23082         return (int64_t)ret_conv;
23083 }
23084
23085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23086         LDKUnsignedChannelUpdate o_conv;
23087         o_conv.inner = (void*)(o & (~1));
23088         o_conv.is_owned = (o & 1) || (o == 0);
23089         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23090         o_conv = UnsignedChannelUpdate_clone(&o_conv);
23091         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23092         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
23093         return (int64_t)ret_conv;
23094 }
23095
23096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23097         LDKDecodeError e_conv;
23098         e_conv.inner = (void*)(e & (~1));
23099         e_conv.is_owned = (e & 1) || (e == 0);
23100         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23101         e_conv = DecodeError_clone(&e_conv);
23102         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23103         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
23104         return (int64_t)ret_conv;
23105 }
23106
23107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23108         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
23109         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
23110         return ret_conv;
23111 }
23112
23113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23114         if ((_res & 1) != 0) return;
23115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23116         CHECK_ACCESS(_res_ptr);
23117         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
23118         FREE((void*)_res);
23119         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
23120 }
23121
23122 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23123         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23124         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
23125         return (int64_t)ret_conv;
23126 }
23127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23128         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
23129         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23130         return ret_conv;
23131 }
23132
23133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23134         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
23135         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23136         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
23137         return (int64_t)ret_conv;
23138 }
23139
23140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23141         LDKChannelUpdate o_conv;
23142         o_conv.inner = (void*)(o & (~1));
23143         o_conv.is_owned = (o & 1) || (o == 0);
23144         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23145         o_conv = ChannelUpdate_clone(&o_conv);
23146         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23147         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
23148         return (int64_t)ret_conv;
23149 }
23150
23151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23152         LDKDecodeError e_conv;
23153         e_conv.inner = (void*)(e & (~1));
23154         e_conv.is_owned = (e & 1) || (e == 0);
23155         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23156         e_conv = DecodeError_clone(&e_conv);
23157         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23158         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
23159         return (int64_t)ret_conv;
23160 }
23161
23162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23163         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
23164         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
23165         return ret_conv;
23166 }
23167
23168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23169         if ((_res & 1) != 0) return;
23170         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23171         CHECK_ACCESS(_res_ptr);
23172         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
23173         FREE((void*)_res);
23174         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
23175 }
23176
23177 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23178         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23179         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
23180         return (int64_t)ret_conv;
23181 }
23182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23183         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
23184         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23185         return ret_conv;
23186 }
23187
23188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23189         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
23190         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23191         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
23192         return (int64_t)ret_conv;
23193 }
23194
23195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23196         LDKErrorMessage o_conv;
23197         o_conv.inner = (void*)(o & (~1));
23198         o_conv.is_owned = (o & 1) || (o == 0);
23199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23200         o_conv = ErrorMessage_clone(&o_conv);
23201         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23202         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
23203         return (int64_t)ret_conv;
23204 }
23205
23206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23207         LDKDecodeError e_conv;
23208         e_conv.inner = (void*)(e & (~1));
23209         e_conv.is_owned = (e & 1) || (e == 0);
23210         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23211         e_conv = DecodeError_clone(&e_conv);
23212         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23213         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
23214         return (int64_t)ret_conv;
23215 }
23216
23217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23218         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
23219         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
23220         return ret_conv;
23221 }
23222
23223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23224         if ((_res & 1) != 0) return;
23225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23226         CHECK_ACCESS(_res_ptr);
23227         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
23228         FREE((void*)_res);
23229         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
23230 }
23231
23232 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
23233         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23234         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
23235         return (int64_t)ret_conv;
23236 }
23237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23238         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
23239         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
23240         return ret_conv;
23241 }
23242
23243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23244         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
23245         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23246         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
23247         return (int64_t)ret_conv;
23248 }
23249
23250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23251         LDKWarningMessage o_conv;
23252         o_conv.inner = (void*)(o & (~1));
23253         o_conv.is_owned = (o & 1) || (o == 0);
23254         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23255         o_conv = WarningMessage_clone(&o_conv);
23256         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23257         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
23258         return (int64_t)ret_conv;
23259 }
23260
23261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23262         LDKDecodeError e_conv;
23263         e_conv.inner = (void*)(e & (~1));
23264         e_conv.is_owned = (e & 1) || (e == 0);
23265         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23266         e_conv = DecodeError_clone(&e_conv);
23267         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23268         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
23269         return (int64_t)ret_conv;
23270 }
23271
23272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23273         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
23274         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
23275         return ret_conv;
23276 }
23277
23278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23279         if ((_res & 1) != 0) return;
23280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23281         CHECK_ACCESS(_res_ptr);
23282         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
23283         FREE((void*)_res);
23284         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
23285 }
23286
23287 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
23288         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23289         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
23290         return (int64_t)ret_conv;
23291 }
23292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23293         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
23294         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
23295         return ret_conv;
23296 }
23297
23298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23299         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
23300         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23301         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
23302         return (int64_t)ret_conv;
23303 }
23304
23305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23306         LDKUnsignedNodeAnnouncement o_conv;
23307         o_conv.inner = (void*)(o & (~1));
23308         o_conv.is_owned = (o & 1) || (o == 0);
23309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23310         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
23311         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23312         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
23313         return (int64_t)ret_conv;
23314 }
23315
23316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23317         LDKDecodeError e_conv;
23318         e_conv.inner = (void*)(e & (~1));
23319         e_conv.is_owned = (e & 1) || (e == 0);
23320         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23321         e_conv = DecodeError_clone(&e_conv);
23322         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23323         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
23324         return (int64_t)ret_conv;
23325 }
23326
23327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23328         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
23329         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23330         return ret_conv;
23331 }
23332
23333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23334         if ((_res & 1) != 0) return;
23335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23336         CHECK_ACCESS(_res_ptr);
23337         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
23338         FREE((void*)_res);
23339         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
23340 }
23341
23342 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23343         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23344         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
23345         return (int64_t)ret_conv;
23346 }
23347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23348         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
23349         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23350         return ret_conv;
23351 }
23352
23353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23354         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
23355         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23356         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
23357         return (int64_t)ret_conv;
23358 }
23359
23360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23361         LDKNodeAnnouncement o_conv;
23362         o_conv.inner = (void*)(o & (~1));
23363         o_conv.is_owned = (o & 1) || (o == 0);
23364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23365         o_conv = NodeAnnouncement_clone(&o_conv);
23366         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23367         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
23368         return (int64_t)ret_conv;
23369 }
23370
23371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23372         LDKDecodeError e_conv;
23373         e_conv.inner = (void*)(e & (~1));
23374         e_conv.is_owned = (e & 1) || (e == 0);
23375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23376         e_conv = DecodeError_clone(&e_conv);
23377         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23378         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
23379         return (int64_t)ret_conv;
23380 }
23381
23382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23383         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
23384         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23385         return ret_conv;
23386 }
23387
23388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23389         if ((_res & 1) != 0) return;
23390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23391         CHECK_ACCESS(_res_ptr);
23392         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
23393         FREE((void*)_res);
23394         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
23395 }
23396
23397 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23398         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23399         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
23400         return (int64_t)ret_conv;
23401 }
23402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23403         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
23404         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23405         return ret_conv;
23406 }
23407
23408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23409         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
23410         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23411         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
23412         return (int64_t)ret_conv;
23413 }
23414
23415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23416         LDKQueryShortChannelIds o_conv;
23417         o_conv.inner = (void*)(o & (~1));
23418         o_conv.is_owned = (o & 1) || (o == 0);
23419         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23420         o_conv = QueryShortChannelIds_clone(&o_conv);
23421         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23422         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
23423         return (int64_t)ret_conv;
23424 }
23425
23426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23427         LDKDecodeError e_conv;
23428         e_conv.inner = (void*)(e & (~1));
23429         e_conv.is_owned = (e & 1) || (e == 0);
23430         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23431         e_conv = DecodeError_clone(&e_conv);
23432         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23433         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
23434         return (int64_t)ret_conv;
23435 }
23436
23437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23438         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
23439         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
23440         return ret_conv;
23441 }
23442
23443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23444         if ((_res & 1) != 0) return;
23445         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23446         CHECK_ACCESS(_res_ptr);
23447         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
23448         FREE((void*)_res);
23449         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
23450 }
23451
23452 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
23453         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23454         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
23455         return (int64_t)ret_conv;
23456 }
23457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23458         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
23459         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
23460         return ret_conv;
23461 }
23462
23463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23464         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
23465         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23466         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
23467         return (int64_t)ret_conv;
23468 }
23469
23470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23471         LDKReplyShortChannelIdsEnd o_conv;
23472         o_conv.inner = (void*)(o & (~1));
23473         o_conv.is_owned = (o & 1) || (o == 0);
23474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23475         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
23476         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23477         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
23478         return (int64_t)ret_conv;
23479 }
23480
23481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23482         LDKDecodeError e_conv;
23483         e_conv.inner = (void*)(e & (~1));
23484         e_conv.is_owned = (e & 1) || (e == 0);
23485         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23486         e_conv = DecodeError_clone(&e_conv);
23487         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23488         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
23489         return (int64_t)ret_conv;
23490 }
23491
23492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23493         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
23494         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
23495         return ret_conv;
23496 }
23497
23498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23499         if ((_res & 1) != 0) return;
23500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23501         CHECK_ACCESS(_res_ptr);
23502         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
23503         FREE((void*)_res);
23504         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
23505 }
23506
23507 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
23508         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23509         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
23510         return (int64_t)ret_conv;
23511 }
23512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23513         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
23514         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
23515         return ret_conv;
23516 }
23517
23518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23519         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
23520         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23521         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
23522         return (int64_t)ret_conv;
23523 }
23524
23525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23526         LDKQueryChannelRange o_conv;
23527         o_conv.inner = (void*)(o & (~1));
23528         o_conv.is_owned = (o & 1) || (o == 0);
23529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23530         o_conv = QueryChannelRange_clone(&o_conv);
23531         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23532         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
23533         return (int64_t)ret_conv;
23534 }
23535
23536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23537         LDKDecodeError e_conv;
23538         e_conv.inner = (void*)(e & (~1));
23539         e_conv.is_owned = (e & 1) || (e == 0);
23540         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23541         e_conv = DecodeError_clone(&e_conv);
23542         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23543         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
23544         return (int64_t)ret_conv;
23545 }
23546
23547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23548         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
23549         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
23550         return ret_conv;
23551 }
23552
23553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23554         if ((_res & 1) != 0) return;
23555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23556         CHECK_ACCESS(_res_ptr);
23557         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
23558         FREE((void*)_res);
23559         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
23560 }
23561
23562 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23563         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23564         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
23565         return (int64_t)ret_conv;
23566 }
23567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23568         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
23569         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
23570         return ret_conv;
23571 }
23572
23573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23574         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
23575         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23576         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
23577         return (int64_t)ret_conv;
23578 }
23579
23580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23581         LDKReplyChannelRange o_conv;
23582         o_conv.inner = (void*)(o & (~1));
23583         o_conv.is_owned = (o & 1) || (o == 0);
23584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23585         o_conv = ReplyChannelRange_clone(&o_conv);
23586         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23587         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
23588         return (int64_t)ret_conv;
23589 }
23590
23591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23592         LDKDecodeError e_conv;
23593         e_conv.inner = (void*)(e & (~1));
23594         e_conv.is_owned = (e & 1) || (e == 0);
23595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23596         e_conv = DecodeError_clone(&e_conv);
23597         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23598         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
23599         return (int64_t)ret_conv;
23600 }
23601
23602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23603         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
23604         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
23605         return ret_conv;
23606 }
23607
23608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23609         if ((_res & 1) != 0) return;
23610         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23611         CHECK_ACCESS(_res_ptr);
23612         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
23613         FREE((void*)_res);
23614         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
23615 }
23616
23617 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23618         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23619         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
23620         return (int64_t)ret_conv;
23621 }
23622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23623         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
23624         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
23625         return ret_conv;
23626 }
23627
23628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23629         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
23630         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23631         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
23632         return (int64_t)ret_conv;
23633 }
23634
23635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23636         LDKGossipTimestampFilter o_conv;
23637         o_conv.inner = (void*)(o & (~1));
23638         o_conv.is_owned = (o & 1) || (o == 0);
23639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23640         o_conv = GossipTimestampFilter_clone(&o_conv);
23641         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23642         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
23643         return (int64_t)ret_conv;
23644 }
23645
23646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23647         LDKDecodeError e_conv;
23648         e_conv.inner = (void*)(e & (~1));
23649         e_conv.is_owned = (e & 1) || (e == 0);
23650         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23651         e_conv = DecodeError_clone(&e_conv);
23652         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23653         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
23654         return (int64_t)ret_conv;
23655 }
23656
23657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23658         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
23659         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
23660         return ret_conv;
23661 }
23662
23663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23664         if ((_res & 1) != 0) return;
23665         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23666         CHECK_ACCESS(_res_ptr);
23667         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
23668         FREE((void*)_res);
23669         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
23670 }
23671
23672 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
23673         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23674         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
23675         return (int64_t)ret_conv;
23676 }
23677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23678         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
23679         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
23680         return ret_conv;
23681 }
23682
23683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23684         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
23685         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23686         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
23687         return (int64_t)ret_conv;
23688 }
23689
23690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23691         LDKCVec_PhantomRouteHintsZ _res_constr;
23692         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23693         if (_res_constr.datalen > 0)
23694                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
23695         else
23696                 _res_constr.data = NULL;
23697         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23698         for (size_t t = 0; t < _res_constr.datalen; t++) {
23699                 int64_t _res_conv_19 = _res_vals[t];
23700                 LDKPhantomRouteHints _res_conv_19_conv;
23701                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
23702                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
23703                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23704                 _res_constr.data[t] = _res_conv_19_conv;
23705         }
23706         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23707         CVec_PhantomRouteHintsZ_free(_res_constr);
23708 }
23709
23710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23711         LDKInvoice o_conv;
23712         o_conv.inner = (void*)(o & (~1));
23713         o_conv.is_owned = (o & 1) || (o == 0);
23714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23715         o_conv = Invoice_clone(&o_conv);
23716         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23717         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
23718         return (int64_t)ret_conv;
23719 }
23720
23721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23722         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
23723         CHECK_ACCESS(e_ptr);
23724         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
23725         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
23726         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23727         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
23728         return (int64_t)ret_conv;
23729 }
23730
23731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23732         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
23733         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
23734         return ret_conv;
23735 }
23736
23737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23738         if ((_res & 1) != 0) return;
23739         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23740         CHECK_ACCESS(_res_ptr);
23741         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
23742         FREE((void*)_res);
23743         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
23744 }
23745
23746 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
23747         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23748         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
23749         return (int64_t)ret_conv;
23750 }
23751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23752         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
23753         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
23754         return ret_conv;
23755 }
23756
23757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23758         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
23759         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23760         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
23761         return (int64_t)ret_conv;
23762 }
23763
23764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23765         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
23766         CHECK_ACCESS(o_ptr);
23767         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
23768         if (o_conv.free == LDKFilter_JCalls_free) {
23769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23770                 LDKFilter_JCalls_cloned(&o_conv);
23771         }
23772         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23773         *ret_copy = COption_FilterZ_some(o_conv);
23774         int64_t ret_ref = (uintptr_t)ret_copy;
23775         return ret_ref;
23776 }
23777
23778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
23779         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23780         *ret_copy = COption_FilterZ_none();
23781         int64_t ret_ref = (uintptr_t)ret_copy;
23782         return ret_ref;
23783 }
23784
23785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23786         if ((_res & 1) != 0) return;
23787         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23788         CHECK_ACCESS(_res_ptr);
23789         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
23790         FREE((void*)_res);
23791         COption_FilterZ_free(_res_conv);
23792 }
23793
23794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23795         LDKLockedChannelMonitor o_conv;
23796         o_conv.inner = (void*)(o & (~1));
23797         o_conv.is_owned = (o & 1) || (o == 0);
23798         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23799         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
23800         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23801         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
23802         return (int64_t)ret_conv;
23803 }
23804
23805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
23806         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23807         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
23808         return (int64_t)ret_conv;
23809 }
23810
23811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23812         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
23813         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
23814         return ret_conv;
23815 }
23816
23817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23818         if ((_res & 1) != 0) return;
23819         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23820         CHECK_ACCESS(_res_ptr);
23821         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
23822         FREE((void*)_res);
23823         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
23824 }
23825
23826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23827         LDKCVec_OutPointZ _res_constr;
23828         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23829         if (_res_constr.datalen > 0)
23830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
23831         else
23832                 _res_constr.data = NULL;
23833         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23834         for (size_t k = 0; k < _res_constr.datalen; k++) {
23835                 int64_t _res_conv_10 = _res_vals[k];
23836                 LDKOutPoint _res_conv_10_conv;
23837                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
23838                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
23839                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
23840                 _res_constr.data[k] = _res_conv_10_conv;
23841         }
23842         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23843         CVec_OutPointZ_free(_res_constr);
23844 }
23845
23846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23847         if ((this_ptr & 1) != 0) return;
23848         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23849         CHECK_ACCESS(this_ptr_ptr);
23850         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
23851         FREE((void*)this_ptr);
23852         PaymentPurpose_free(this_ptr_conv);
23853 }
23854
23855 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23856         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23857         *ret_copy = PaymentPurpose_clone(arg);
23858 int64_t ret_ref = (uintptr_t)ret_copy;
23859         return ret_ref;
23860 }
23861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23862         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
23863         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
23864         return ret_conv;
23865 }
23866
23867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23868         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
23869         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23870         *ret_copy = PaymentPurpose_clone(orig_conv);
23871         int64_t ret_ref = (uintptr_t)ret_copy;
23872         return ret_ref;
23873 }
23874
23875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23876         LDKThirtyTwoBytes payment_preimage_ref;
23877         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23878         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23879         LDKThirtyTwoBytes payment_secret_ref;
23880         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23881         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23882         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23883         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23884         int64_t ret_ref = (uintptr_t)ret_copy;
23885         return ret_ref;
23886 }
23887
23888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23889         LDKThirtyTwoBytes a_ref;
23890         CHECK((*env)->GetArrayLength(env, a) == 32);
23891         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23892         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23893         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23894         int64_t ret_ref = (uintptr_t)ret_copy;
23895         return ret_ref;
23896 }
23897
23898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
23899         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
23900         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
23901         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23902         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23903         CVec_u8Z_free(ret_var);
23904         return ret_arr;
23905 }
23906
23907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23908         LDKu8slice ser_ref;
23909         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23910         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23911         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
23912         *ret_conv = PaymentPurpose_read(ser_ref);
23913         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23914         return (int64_t)ret_conv;
23915 }
23916
23917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23918         if ((this_ptr & 1) != 0) return;
23919         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23920         CHECK_ACCESS(this_ptr_ptr);
23921         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23922         FREE((void*)this_ptr);
23923         ClosureReason_free(this_ptr_conv);
23924 }
23925
23926 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23927         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23928         *ret_copy = ClosureReason_clone(arg);
23929 int64_t ret_ref = (uintptr_t)ret_copy;
23930         return ret_ref;
23931 }
23932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23933         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
23934         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
23935         return ret_conv;
23936 }
23937
23938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23939         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
23940         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23941         *ret_copy = ClosureReason_clone(orig_conv);
23942         int64_t ret_ref = (uintptr_t)ret_copy;
23943         return ret_ref;
23944 }
23945
23946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23947         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23948         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23949         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23950         int64_t ret_ref = (uintptr_t)ret_copy;
23951         return ret_ref;
23952 }
23953
23954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23955         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23956         *ret_copy = ClosureReason_holder_force_closed();
23957         int64_t ret_ref = (uintptr_t)ret_copy;
23958         return ret_ref;
23959 }
23960
23961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23962         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23963         *ret_copy = ClosureReason_cooperative_closure();
23964         int64_t ret_ref = (uintptr_t)ret_copy;
23965         return ret_ref;
23966 }
23967
23968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23969         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23970         *ret_copy = ClosureReason_commitment_tx_confirmed();
23971         int64_t ret_ref = (uintptr_t)ret_copy;
23972         return ret_ref;
23973 }
23974
23975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23976         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23977         *ret_copy = ClosureReason_funding_timed_out();
23978         int64_t ret_ref = (uintptr_t)ret_copy;
23979         return ret_ref;
23980 }
23981
23982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23983         LDKStr err_conv = java_to_owned_str(env, err);
23984         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23985         *ret_copy = ClosureReason_processing_error(err_conv);
23986         int64_t ret_ref = (uintptr_t)ret_copy;
23987         return ret_ref;
23988 }
23989
23990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23991         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23992         *ret_copy = ClosureReason_disconnected_peer();
23993         int64_t ret_ref = (uintptr_t)ret_copy;
23994         return ret_ref;
23995 }
23996
23997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23998         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23999         *ret_copy = ClosureReason_outdated_channel_manager();
24000         int64_t ret_ref = (uintptr_t)ret_copy;
24001         return ret_ref;
24002 }
24003
24004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
24005         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
24006         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
24007         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24008         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24009         CVec_u8Z_free(ret_var);
24010         return ret_arr;
24011 }
24012
24013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24014         LDKu8slice ser_ref;
24015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24017         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
24018         *ret_conv = ClosureReason_read(ser_ref);
24019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24020         return (int64_t)ret_conv;
24021 }
24022
24023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24024         if ((this_ptr & 1) != 0) return;
24025         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24026         CHECK_ACCESS(this_ptr_ptr);
24027         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
24028         FREE((void*)this_ptr);
24029         Event_free(this_ptr_conv);
24030 }
24031
24032 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
24033         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24034         *ret_copy = Event_clone(arg);
24035 int64_t ret_ref = (uintptr_t)ret_copy;
24036         return ret_ref;
24037 }
24038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24039         LDKEvent* arg_conv = (LDKEvent*)arg;
24040         int64_t ret_conv = Event_clone_ptr(arg_conv);
24041         return ret_conv;
24042 }
24043
24044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24045         LDKEvent* orig_conv = (LDKEvent*)orig;
24046         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24047         *ret_copy = Event_clone(orig_conv);
24048         int64_t ret_ref = (uintptr_t)ret_copy;
24049         return ret_ref;
24050 }
24051
24052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
24053         LDKThirtyTwoBytes temporary_channel_id_ref;
24054         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24055         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24056         LDKPublicKey counterparty_node_id_ref;
24057         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24058         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24059         LDKCVec_u8Z output_script_ref;
24060         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
24061         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
24062         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
24063         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24064         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
24065         int64_t ret_ref = (uintptr_t)ret_copy;
24066         return ret_ref;
24067 }
24068
24069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
24070         LDKThirtyTwoBytes payment_hash_ref;
24071         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24072         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24073         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24074         CHECK_ACCESS(purpose_ptr);
24075         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24076         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24077         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24078         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
24079         int64_t ret_ref = (uintptr_t)ret_copy;
24080         return ret_ref;
24081 }
24082
24083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
24084         LDKThirtyTwoBytes payment_hash_ref;
24085         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24086         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24087         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24088         CHECK_ACCESS(purpose_ptr);
24089         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24090         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24091         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24092         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
24093         int64_t ret_ref = (uintptr_t)ret_copy;
24094         return ret_ref;
24095 }
24096
24097 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) {
24098         LDKThirtyTwoBytes payment_id_ref;
24099         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24100         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24101         LDKThirtyTwoBytes payment_preimage_ref;
24102         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24103         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24104         LDKThirtyTwoBytes payment_hash_ref;
24105         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24106         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24107         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
24108         CHECK_ACCESS(fee_paid_msat_ptr);
24109         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
24110         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
24111         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24112         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
24113         int64_t ret_ref = (uintptr_t)ret_copy;
24114         return ret_ref;
24115 }
24116
24117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
24118         LDKThirtyTwoBytes payment_id_ref;
24119         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24120         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24121         LDKThirtyTwoBytes payment_hash_ref;
24122         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24123         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24124         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24125         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
24126         int64_t ret_ref = (uintptr_t)ret_copy;
24127         return ret_ref;
24128 }
24129
24130 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) {
24131         LDKThirtyTwoBytes payment_id_ref;
24132         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24133         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24134         LDKThirtyTwoBytes payment_hash_ref;
24135         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24136         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24137         LDKCVec_RouteHopZ path_constr;
24138         path_constr.datalen = (*env)->GetArrayLength(env, path);
24139         if (path_constr.datalen > 0)
24140                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24141         else
24142                 path_constr.data = NULL;
24143         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24144         for (size_t k = 0; k < path_constr.datalen; k++) {
24145                 int64_t path_conv_10 = path_vals[k];
24146                 LDKRouteHop path_conv_10_conv;
24147                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24148                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24149                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24150                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24151                 path_constr.data[k] = path_conv_10_conv;
24152         }
24153         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24154         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24155         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
24156         int64_t ret_ref = (uintptr_t)ret_copy;
24157         return ret_ref;
24158 }
24159
24160 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) {
24161         LDKThirtyTwoBytes payment_id_ref;
24162         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24163         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24164         LDKThirtyTwoBytes payment_hash_ref;
24165         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24166         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24167         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
24168         CHECK_ACCESS(network_update_ptr);
24169         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
24170         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
24171         LDKCVec_RouteHopZ path_constr;
24172         path_constr.datalen = (*env)->GetArrayLength(env, path);
24173         if (path_constr.datalen > 0)
24174                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24175         else
24176                 path_constr.data = NULL;
24177         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24178         for (size_t k = 0; k < path_constr.datalen; k++) {
24179                 int64_t path_conv_10 = path_vals[k];
24180                 LDKRouteHop path_conv_10_conv;
24181                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24182                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24183                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24184                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24185                 path_constr.data[k] = path_conv_10_conv;
24186         }
24187         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24188         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24189         CHECK_ACCESS(short_channel_id_ptr);
24190         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24191         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24192         LDKRouteParameters retry_conv;
24193         retry_conv.inner = (void*)(retry & (~1));
24194         retry_conv.is_owned = (retry & 1) || (retry == 0);
24195         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
24196         retry_conv = RouteParameters_clone(&retry_conv);
24197         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24198         *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);
24199         int64_t ret_ref = (uintptr_t)ret_copy;
24200         return ret_ref;
24201 }
24202
24203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
24204         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24205         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
24206         int64_t ret_ref = (uintptr_t)ret_copy;
24207         return ret_ref;
24208 }
24209
24210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
24211         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
24212         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
24213         if (outputs_constr.datalen > 0)
24214                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24215         else
24216                 outputs_constr.data = NULL;
24217         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
24218         for (size_t b = 0; b < outputs_constr.datalen; b++) {
24219                 int64_t outputs_conv_27 = outputs_vals[b];
24220                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
24221                 CHECK_ACCESS(outputs_conv_27_ptr);
24222                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
24223                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
24224                 outputs_constr.data[b] = outputs_conv_27_conv;
24225         }
24226         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
24227         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24228         *ret_copy = Event_spendable_outputs(outputs_constr);
24229         int64_t ret_ref = (uintptr_t)ret_copy;
24230         return ret_ref;
24231 }
24232
24233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
24234         LDKThirtyTwoBytes prev_channel_id_ref;
24235         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24236         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24237         LDKThirtyTwoBytes next_channel_id_ref;
24238         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
24239         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
24240         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
24241         CHECK_ACCESS(fee_earned_msat_ptr);
24242         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
24243         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
24244         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24245         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
24246         int64_t ret_ref = (uintptr_t)ret_copy;
24247         return ret_ref;
24248 }
24249
24250 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) {
24251         LDKThirtyTwoBytes channel_id_ref;
24252         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24253         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24254         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
24255         CHECK_ACCESS(reason_ptr);
24256         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
24257         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
24258         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24259         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
24260         int64_t ret_ref = (uintptr_t)ret_copy;
24261         return ret_ref;
24262 }
24263
24264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
24265         LDKThirtyTwoBytes channel_id_ref;
24266         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24267         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24268         LDKTransaction transaction_ref;
24269         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
24270         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
24271         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
24272         transaction_ref.data_is_owned = true;
24273         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24274         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
24275         int64_t ret_ref = (uintptr_t)ret_copy;
24276         return ret_ref;
24277 }
24278
24279 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) {
24280         LDKThirtyTwoBytes temporary_channel_id_ref;
24281         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24282         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24283         LDKPublicKey counterparty_node_id_ref;
24284         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24285         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24286         LDKChannelTypeFeatures channel_type_conv;
24287         channel_type_conv.inner = (void*)(channel_type & (~1));
24288         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
24289         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
24290         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
24291         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24292         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
24293         int64_t ret_ref = (uintptr_t)ret_copy;
24294         return ret_ref;
24295 }
24296
24297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
24298         LDKEvent* obj_conv = (LDKEvent*)obj;
24299         LDKCVec_u8Z ret_var = Event_write(obj_conv);
24300         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24301         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24302         CVec_u8Z_free(ret_var);
24303         return ret_arr;
24304 }
24305
24306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24307         LDKu8slice ser_ref;
24308         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24309         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24310         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
24311         *ret_conv = Event_read(ser_ref);
24312         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24313         return (int64_t)ret_conv;
24314 }
24315
24316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24317         if ((this_ptr & 1) != 0) return;
24318         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24319         CHECK_ACCESS(this_ptr_ptr);
24320         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
24321         FREE((void*)this_ptr);
24322         MessageSendEvent_free(this_ptr_conv);
24323 }
24324
24325 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
24326         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24327         *ret_copy = MessageSendEvent_clone(arg);
24328 int64_t ret_ref = (uintptr_t)ret_copy;
24329         return ret_ref;
24330 }
24331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24332         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
24333         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
24334         return ret_conv;
24335 }
24336
24337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24338         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
24339         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24340         *ret_copy = MessageSendEvent_clone(orig_conv);
24341         int64_t ret_ref = (uintptr_t)ret_copy;
24342         return ret_ref;
24343 }
24344
24345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24346         LDKPublicKey node_id_ref;
24347         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24348         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24349         LDKAcceptChannel msg_conv;
24350         msg_conv.inner = (void*)(msg & (~1));
24351         msg_conv.is_owned = (msg & 1) || (msg == 0);
24352         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24353         msg_conv = AcceptChannel_clone(&msg_conv);
24354         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24355         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
24356         int64_t ret_ref = (uintptr_t)ret_copy;
24357         return ret_ref;
24358 }
24359
24360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24361         LDKPublicKey node_id_ref;
24362         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24363         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24364         LDKOpenChannel msg_conv;
24365         msg_conv.inner = (void*)(msg & (~1));
24366         msg_conv.is_owned = (msg & 1) || (msg == 0);
24367         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24368         msg_conv = OpenChannel_clone(&msg_conv);
24369         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24370         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
24371         int64_t ret_ref = (uintptr_t)ret_copy;
24372         return ret_ref;
24373 }
24374
24375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24376         LDKPublicKey node_id_ref;
24377         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24378         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24379         LDKFundingCreated msg_conv;
24380         msg_conv.inner = (void*)(msg & (~1));
24381         msg_conv.is_owned = (msg & 1) || (msg == 0);
24382         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24383         msg_conv = FundingCreated_clone(&msg_conv);
24384         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24385         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
24386         int64_t ret_ref = (uintptr_t)ret_copy;
24387         return ret_ref;
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24391         LDKPublicKey node_id_ref;
24392         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24393         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24394         LDKFundingSigned msg_conv;
24395         msg_conv.inner = (void*)(msg & (~1));
24396         msg_conv.is_owned = (msg & 1) || (msg == 0);
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24398         msg_conv = FundingSigned_clone(&msg_conv);
24399         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24400         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
24401         int64_t ret_ref = (uintptr_t)ret_copy;
24402         return ret_ref;
24403 }
24404
24405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24406         LDKPublicKey node_id_ref;
24407         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24408         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24409         LDKChannelReady msg_conv;
24410         msg_conv.inner = (void*)(msg & (~1));
24411         msg_conv.is_owned = (msg & 1) || (msg == 0);
24412         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24413         msg_conv = ChannelReady_clone(&msg_conv);
24414         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24415         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
24416         int64_t ret_ref = (uintptr_t)ret_copy;
24417         return ret_ref;
24418 }
24419
24420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24421         LDKPublicKey node_id_ref;
24422         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24423         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24424         LDKAnnouncementSignatures msg_conv;
24425         msg_conv.inner = (void*)(msg & (~1));
24426         msg_conv.is_owned = (msg & 1) || (msg == 0);
24427         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24428         msg_conv = AnnouncementSignatures_clone(&msg_conv);
24429         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24430         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
24431         int64_t ret_ref = (uintptr_t)ret_copy;
24432         return ret_ref;
24433 }
24434
24435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
24436         LDKPublicKey node_id_ref;
24437         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24438         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24439         LDKCommitmentUpdate updates_conv;
24440         updates_conv.inner = (void*)(updates & (~1));
24441         updates_conv.is_owned = (updates & 1) || (updates == 0);
24442         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
24443         updates_conv = CommitmentUpdate_clone(&updates_conv);
24444         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24445         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
24446         int64_t ret_ref = (uintptr_t)ret_copy;
24447         return ret_ref;
24448 }
24449
24450 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) {
24451         LDKPublicKey node_id_ref;
24452         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24453         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24454         LDKRevokeAndACK msg_conv;
24455         msg_conv.inner = (void*)(msg & (~1));
24456         msg_conv.is_owned = (msg & 1) || (msg == 0);
24457         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24458         msg_conv = RevokeAndACK_clone(&msg_conv);
24459         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24460         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
24461         int64_t ret_ref = (uintptr_t)ret_copy;
24462         return ret_ref;
24463 }
24464
24465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24466         LDKPublicKey node_id_ref;
24467         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24468         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24469         LDKClosingSigned msg_conv;
24470         msg_conv.inner = (void*)(msg & (~1));
24471         msg_conv.is_owned = (msg & 1) || (msg == 0);
24472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24473         msg_conv = ClosingSigned_clone(&msg_conv);
24474         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24475         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
24476         int64_t ret_ref = (uintptr_t)ret_copy;
24477         return ret_ref;
24478 }
24479
24480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24481         LDKPublicKey node_id_ref;
24482         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24483         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24484         LDKShutdown msg_conv;
24485         msg_conv.inner = (void*)(msg & (~1));
24486         msg_conv.is_owned = (msg & 1) || (msg == 0);
24487         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24488         msg_conv = Shutdown_clone(&msg_conv);
24489         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24490         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
24491         int64_t ret_ref = (uintptr_t)ret_copy;
24492         return ret_ref;
24493 }
24494
24495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24496         LDKPublicKey node_id_ref;
24497         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24498         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24499         LDKChannelReestablish msg_conv;
24500         msg_conv.inner = (void*)(msg & (~1));
24501         msg_conv.is_owned = (msg & 1) || (msg == 0);
24502         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24503         msg_conv = ChannelReestablish_clone(&msg_conv);
24504         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24505         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
24506         int64_t ret_ref = (uintptr_t)ret_copy;
24507         return ret_ref;
24508 }
24509
24510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
24511         LDKChannelAnnouncement msg_conv;
24512         msg_conv.inner = (void*)(msg & (~1));
24513         msg_conv.is_owned = (msg & 1) || (msg == 0);
24514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24515         msg_conv = ChannelAnnouncement_clone(&msg_conv);
24516         LDKChannelUpdate update_msg_conv;
24517         update_msg_conv.inner = (void*)(update_msg & (~1));
24518         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
24519         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
24520         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
24521         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24522         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
24523         int64_t ret_ref = (uintptr_t)ret_copy;
24524         return ret_ref;
24525 }
24526
24527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
24528         LDKNodeAnnouncement msg_conv;
24529         msg_conv.inner = (void*)(msg & (~1));
24530         msg_conv.is_owned = (msg & 1) || (msg == 0);
24531         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24532         msg_conv = NodeAnnouncement_clone(&msg_conv);
24533         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24534         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
24535         int64_t ret_ref = (uintptr_t)ret_copy;
24536         return ret_ref;
24537 }
24538
24539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
24540         LDKChannelUpdate msg_conv;
24541         msg_conv.inner = (void*)(msg & (~1));
24542         msg_conv.is_owned = (msg & 1) || (msg == 0);
24543         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24544         msg_conv = ChannelUpdate_clone(&msg_conv);
24545         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24546         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
24547         int64_t ret_ref = (uintptr_t)ret_copy;
24548         return ret_ref;
24549 }
24550
24551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24552         LDKPublicKey node_id_ref;
24553         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24554         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24555         LDKChannelUpdate msg_conv;
24556         msg_conv.inner = (void*)(msg & (~1));
24557         msg_conv.is_owned = (msg & 1) || (msg == 0);
24558         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24559         msg_conv = ChannelUpdate_clone(&msg_conv);
24560         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24561         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
24562         int64_t ret_ref = (uintptr_t)ret_copy;
24563         return ret_ref;
24564 }
24565
24566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
24567         LDKPublicKey node_id_ref;
24568         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24569         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24570         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
24571         CHECK_ACCESS(action_ptr);
24572         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
24573         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
24574         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24575         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
24576         int64_t ret_ref = (uintptr_t)ret_copy;
24577         return ret_ref;
24578 }
24579
24580 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) {
24581         LDKPublicKey node_id_ref;
24582         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24583         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24584         LDKQueryChannelRange msg_conv;
24585         msg_conv.inner = (void*)(msg & (~1));
24586         msg_conv.is_owned = (msg & 1) || (msg == 0);
24587         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24588         msg_conv = QueryChannelRange_clone(&msg_conv);
24589         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24590         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
24591         int64_t ret_ref = (uintptr_t)ret_copy;
24592         return ret_ref;
24593 }
24594
24595 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) {
24596         LDKPublicKey node_id_ref;
24597         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24598         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24599         LDKQueryShortChannelIds msg_conv;
24600         msg_conv.inner = (void*)(msg & (~1));
24601         msg_conv.is_owned = (msg & 1) || (msg == 0);
24602         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24603         msg_conv = QueryShortChannelIds_clone(&msg_conv);
24604         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24605         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
24606         int64_t ret_ref = (uintptr_t)ret_copy;
24607         return ret_ref;
24608 }
24609
24610 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) {
24611         LDKPublicKey node_id_ref;
24612         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24613         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24614         LDKReplyChannelRange msg_conv;
24615         msg_conv.inner = (void*)(msg & (~1));
24616         msg_conv.is_owned = (msg & 1) || (msg == 0);
24617         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24618         msg_conv = ReplyChannelRange_clone(&msg_conv);
24619         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24620         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
24621         int64_t ret_ref = (uintptr_t)ret_copy;
24622         return ret_ref;
24623 }
24624
24625 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) {
24626         LDKPublicKey node_id_ref;
24627         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24628         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24629         LDKGossipTimestampFilter msg_conv;
24630         msg_conv.inner = (void*)(msg & (~1));
24631         msg_conv.is_owned = (msg & 1) || (msg == 0);
24632         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24633         msg_conv = GossipTimestampFilter_clone(&msg_conv);
24634         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24635         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
24636         int64_t ret_ref = (uintptr_t)ret_copy;
24637         return ret_ref;
24638 }
24639
24640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24641         if ((this_ptr & 1) != 0) return;
24642         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24643         CHECK_ACCESS(this_ptr_ptr);
24644         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
24645         FREE((void*)this_ptr);
24646         MessageSendEventsProvider_free(this_ptr_conv);
24647 }
24648
24649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24650         if ((this_ptr & 1) != 0) return;
24651         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24652         CHECK_ACCESS(this_ptr_ptr);
24653         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
24654         FREE((void*)this_ptr);
24655         EventsProvider_free(this_ptr_conv);
24656 }
24657
24658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24659         if ((this_ptr & 1) != 0) return;
24660         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24661         CHECK_ACCESS(this_ptr_ptr);
24662         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
24663         FREE((void*)this_ptr);
24664         EventHandler_free(this_ptr_conv);
24665 }
24666
24667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24668         if ((this_ptr & 1) != 0) return;
24669         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24670         CHECK_ACCESS(this_ptr_ptr);
24671         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
24672         FREE((void*)this_ptr);
24673         APIError_free(this_ptr_conv);
24674 }
24675
24676 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
24677         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24678         *ret_copy = APIError_clone(arg);
24679 int64_t ret_ref = (uintptr_t)ret_copy;
24680         return ret_ref;
24681 }
24682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24683         LDKAPIError* arg_conv = (LDKAPIError*)arg;
24684         int64_t ret_conv = APIError_clone_ptr(arg_conv);
24685         return ret_conv;
24686 }
24687
24688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24689         LDKAPIError* orig_conv = (LDKAPIError*)orig;
24690         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24691         *ret_copy = APIError_clone(orig_conv);
24692         int64_t ret_ref = (uintptr_t)ret_copy;
24693         return ret_ref;
24694 }
24695
24696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
24697         LDKStr err_conv = java_to_owned_str(env, err);
24698         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24699         *ret_copy = APIError_apimisuse_error(err_conv);
24700         int64_t ret_ref = (uintptr_t)ret_copy;
24701         return ret_ref;
24702 }
24703
24704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
24705         LDKStr err_conv = java_to_owned_str(env, err);
24706         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24707         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
24708         int64_t ret_ref = (uintptr_t)ret_copy;
24709         return ret_ref;
24710 }
24711
24712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
24713         LDKStr err_conv = java_to_owned_str(env, err);
24714         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24715         *ret_copy = APIError_route_error(err_conv);
24716         int64_t ret_ref = (uintptr_t)ret_copy;
24717         return ret_ref;
24718 }
24719
24720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
24721         LDKStr err_conv = java_to_owned_str(env, err);
24722         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24723         *ret_copy = APIError_channel_unavailable(err_conv);
24724         int64_t ret_ref = (uintptr_t)ret_copy;
24725         return ret_ref;
24726 }
24727
24728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
24729         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24730         *ret_copy = APIError_monitor_update_failed();
24731         int64_t ret_ref = (uintptr_t)ret_copy;
24732         return ret_ref;
24733 }
24734
24735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
24736         LDKShutdownScript script_conv;
24737         script_conv.inner = (void*)(script & (~1));
24738         script_conv.is_owned = (script & 1) || (script == 0);
24739         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
24740         script_conv = ShutdownScript_clone(&script_conv);
24741         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24742         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
24743         int64_t ret_ref = (uintptr_t)ret_copy;
24744         return ret_ref;
24745 }
24746
24747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24748         LDKBigSize this_obj_conv;
24749         this_obj_conv.inner = (void*)(this_obj & (~1));
24750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24752         BigSize_free(this_obj_conv);
24753 }
24754
24755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
24756         LDKBigSize this_ptr_conv;
24757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24758         this_ptr_conv.is_owned = false;
24759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24760         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
24761         return ret_conv;
24762 }
24763
24764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24765         LDKBigSize this_ptr_conv;
24766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24767         this_ptr_conv.is_owned = false;
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24769         BigSize_set_a(&this_ptr_conv, val);
24770 }
24771
24772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
24773         LDKBigSize ret_var = BigSize_new(a_arg);
24774         int64_t ret_ref = 0;
24775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24778         ret_ref = (uintptr_t)ret_var.inner;
24779         if (ret_var.is_owned) {
24780                 ret_ref |= 1;
24781         }
24782         return ret_ref;
24783 }
24784
24785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
24786         LDKu8slice msg_ref;
24787         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24788         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24789         unsigned char sk_arr[32];
24790         CHECK((*env)->GetArrayLength(env, sk) == 32);
24791         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
24792         unsigned char (*sk_ref)[32] = &sk_arr;
24793         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
24794         *ret_conv = sign(msg_ref, sk_ref);
24795         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24796         return (int64_t)ret_conv;
24797 }
24798
24799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
24800         LDKu8slice msg_ref;
24801         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24802         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24803         LDKStr sig_conv = java_to_owned_str(env, sig);
24804         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
24805         *ret_conv = recover_pk(msg_ref, sig_conv);
24806         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24807         return (int64_t)ret_conv;
24808 }
24809
24810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
24811         LDKu8slice msg_ref;
24812         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24813         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24814         LDKStr sig_conv = java_to_owned_str(env, sig);
24815         LDKPublicKey pk_ref;
24816         CHECK((*env)->GetArrayLength(env, pk) == 33);
24817         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
24818         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
24819         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24820         return ret_conv;
24821 }
24822
24823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
24824         LDKu8slice hrp_bytes_ref;
24825         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
24826         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
24827         LDKCVec_u5Z data_without_signature_constr;
24828         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
24829         if (data_without_signature_constr.datalen > 0)
24830                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
24831         else
24832                 data_without_signature_constr.data = NULL;
24833         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
24834         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
24835                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
24836                 
24837                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
24838         }
24839         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
24840         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
24841         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24842         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24843         CVec_u8Z_free(ret_var);
24844         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
24845         return ret_arr;
24846 }
24847
24848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24849         if ((this_ptr & 1) != 0) return;
24850         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24851         CHECK_ACCESS(this_ptr_ptr);
24852         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
24853         FREE((void*)this_ptr);
24854         Persister_free(this_ptr_conv);
24855 }
24856
24857 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24858         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
24859         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
24860         return ret_conv;
24861 }
24862
24863 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
24864         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
24865         return ret_conv;
24866 }
24867
24868 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
24869         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
24870         return ret_conv;
24871 }
24872
24873 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
24874         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
24875         return ret_conv;
24876 }
24877
24878 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
24879         jclass ret_conv = LDKLevel_to_java(env, Level_info());
24880         return ret_conv;
24881 }
24882
24883 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24884         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24885         return ret_conv;
24886 }
24887
24888 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24889         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24890         return ret_conv;
24891 }
24892
24893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24894         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
24895         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
24896         jboolean ret_conv = Level_eq(a_conv, b_conv);
24897         return ret_conv;
24898 }
24899
24900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24901         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
24902         int64_t ret_conv = Level_hash(o_conv);
24903         return ret_conv;
24904 }
24905
24906 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24907         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24908         return ret_conv;
24909 }
24910
24911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24912         LDKRecord this_obj_conv;
24913         this_obj_conv.inner = (void*)(this_obj & (~1));
24914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24916         Record_free(this_obj_conv);
24917 }
24918
24919 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24920         LDKRecord this_ptr_conv;
24921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24922         this_ptr_conv.is_owned = false;
24923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24924         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24925         return ret_conv;
24926 }
24927
24928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24929         LDKRecord this_ptr_conv;
24930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24931         this_ptr_conv.is_owned = false;
24932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24933         LDKLevel val_conv = LDKLevel_from_java(env, val);
24934         Record_set_level(&this_ptr_conv, val_conv);
24935 }
24936
24937 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24938         LDKRecord this_ptr_conv;
24939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24940         this_ptr_conv.is_owned = false;
24941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24942         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24943         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24944         Str_free(ret_str);
24945         return ret_conv;
24946 }
24947
24948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24949         LDKRecord this_ptr_conv;
24950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24951         this_ptr_conv.is_owned = false;
24952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24953         LDKStr val_conv = java_to_owned_str(env, val);
24954         Record_set_args(&this_ptr_conv, val_conv);
24955 }
24956
24957 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24958         LDKRecord this_ptr_conv;
24959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24960         this_ptr_conv.is_owned = false;
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24962         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24963         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24964         Str_free(ret_str);
24965         return ret_conv;
24966 }
24967
24968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24969         LDKRecord this_ptr_conv;
24970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24971         this_ptr_conv.is_owned = false;
24972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24973         LDKStr val_conv = java_to_owned_str(env, val);
24974         Record_set_module_path(&this_ptr_conv, val_conv);
24975 }
24976
24977 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24978         LDKRecord this_ptr_conv;
24979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24980         this_ptr_conv.is_owned = false;
24981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24982         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24983         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24984         Str_free(ret_str);
24985         return ret_conv;
24986 }
24987
24988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24989         LDKRecord this_ptr_conv;
24990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24991         this_ptr_conv.is_owned = false;
24992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24993         LDKStr val_conv = java_to_owned_str(env, val);
24994         Record_set_file(&this_ptr_conv, val_conv);
24995 }
24996
24997 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24998         LDKRecord this_ptr_conv;
24999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25000         this_ptr_conv.is_owned = false;
25001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25002         int32_t ret_conv = Record_get_line(&this_ptr_conv);
25003         return ret_conv;
25004 }
25005
25006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25007         LDKRecord this_ptr_conv;
25008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25009         this_ptr_conv.is_owned = false;
25010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25011         Record_set_line(&this_ptr_conv, val);
25012 }
25013
25014 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
25015         LDKRecord ret_var = Record_clone(arg);
25016 int64_t ret_ref = 0;
25017 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25018 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25020 ret_ref = (uintptr_t)ret_var.inner;
25021 if (ret_var.is_owned) {
25022         ret_ref |= 1;
25023 }
25024         return ret_ref;
25025 }
25026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25027         LDKRecord arg_conv;
25028         arg_conv.inner = (void*)(arg & (~1));
25029         arg_conv.is_owned = false;
25030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25031         int64_t ret_conv = Record_clone_ptr(&arg_conv);
25032         return ret_conv;
25033 }
25034
25035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25036         LDKRecord orig_conv;
25037         orig_conv.inner = (void*)(orig & (~1));
25038         orig_conv.is_owned = false;
25039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25040         LDKRecord ret_var = Record_clone(&orig_conv);
25041         int64_t ret_ref = 0;
25042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25045         ret_ref = (uintptr_t)ret_var.inner;
25046         if (ret_var.is_owned) {
25047                 ret_ref |= 1;
25048         }
25049         return ret_ref;
25050 }
25051
25052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25053         if ((this_ptr & 1) != 0) return;
25054         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25055         CHECK_ACCESS(this_ptr_ptr);
25056         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
25057         FREE((void*)this_ptr);
25058         Logger_free(this_ptr_conv);
25059 }
25060
25061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25062         LDKChannelHandshakeConfig this_obj_conv;
25063         this_obj_conv.inner = (void*)(this_obj & (~1));
25064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25066         ChannelHandshakeConfig_free(this_obj_conv);
25067 }
25068
25069 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25070         LDKChannelHandshakeConfig this_ptr_conv;
25071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25072         this_ptr_conv.is_owned = false;
25073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25074         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
25075         return ret_conv;
25076 }
25077
25078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25079         LDKChannelHandshakeConfig this_ptr_conv;
25080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25081         this_ptr_conv.is_owned = false;
25082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25083         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
25084 }
25085
25086 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25087         LDKChannelHandshakeConfig this_ptr_conv;
25088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25089         this_ptr_conv.is_owned = false;
25090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25091         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
25092         return ret_conv;
25093 }
25094
25095 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) {
25096         LDKChannelHandshakeConfig this_ptr_conv;
25097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25098         this_ptr_conv.is_owned = false;
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25100         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
25101 }
25102
25103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25104         LDKChannelHandshakeConfig this_ptr_conv;
25105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25106         this_ptr_conv.is_owned = false;
25107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25108         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
25109         return ret_conv;
25110 }
25111
25112 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) {
25113         LDKChannelHandshakeConfig this_ptr_conv;
25114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25115         this_ptr_conv.is_owned = false;
25116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25117         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
25118 }
25119
25120 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25121         LDKChannelHandshakeConfig this_ptr_conv;
25122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25123         this_ptr_conv.is_owned = false;
25124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25125         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
25126         return ret_conv;
25127 }
25128
25129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
25130         LDKChannelHandshakeConfig this_ptr_conv;
25131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25132         this_ptr_conv.is_owned = false;
25133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25134         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
25135 }
25136
25137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
25138         LDKChannelHandshakeConfig this_ptr_conv;
25139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25140         this_ptr_conv.is_owned = false;
25141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25142         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
25143         return ret_conv;
25144 }
25145
25146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25147         LDKChannelHandshakeConfig this_ptr_conv;
25148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25149         this_ptr_conv.is_owned = false;
25150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25151         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
25152 }
25153
25154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25155         LDKChannelHandshakeConfig this_ptr_conv;
25156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25157         this_ptr_conv.is_owned = false;
25158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25159         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
25160         return ret_conv;
25161 }
25162
25163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25164         LDKChannelHandshakeConfig this_ptr_conv;
25165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25166         this_ptr_conv.is_owned = false;
25167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25168         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
25169 }
25170
25171 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25172         LDKChannelHandshakeConfig this_ptr_conv;
25173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25174         this_ptr_conv.is_owned = false;
25175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25176         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
25177         return ret_conv;
25178 }
25179
25180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25181         LDKChannelHandshakeConfig this_ptr_conv;
25182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25183         this_ptr_conv.is_owned = false;
25184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25185         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
25186 }
25187
25188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
25189         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
25190         int64_t ret_ref = 0;
25191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25194         ret_ref = (uintptr_t)ret_var.inner;
25195         if (ret_var.is_owned) {
25196                 ret_ref |= 1;
25197         }
25198         return ret_ref;
25199 }
25200
25201 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
25202         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
25203 int64_t ret_ref = 0;
25204 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25205 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25206 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25207 ret_ref = (uintptr_t)ret_var.inner;
25208 if (ret_var.is_owned) {
25209         ret_ref |= 1;
25210 }
25211         return ret_ref;
25212 }
25213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25214         LDKChannelHandshakeConfig arg_conv;
25215         arg_conv.inner = (void*)(arg & (~1));
25216         arg_conv.is_owned = false;
25217         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25218         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
25219         return ret_conv;
25220 }
25221
25222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25223         LDKChannelHandshakeConfig orig_conv;
25224         orig_conv.inner = (void*)(orig & (~1));
25225         orig_conv.is_owned = false;
25226         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25227         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
25228         int64_t ret_ref = 0;
25229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25232         ret_ref = (uintptr_t)ret_var.inner;
25233         if (ret_var.is_owned) {
25234                 ret_ref |= 1;
25235         }
25236         return ret_ref;
25237 }
25238
25239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
25240         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
25241         int64_t ret_ref = 0;
25242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25245         ret_ref = (uintptr_t)ret_var.inner;
25246         if (ret_var.is_owned) {
25247                 ret_ref |= 1;
25248         }
25249         return ret_ref;
25250 }
25251
25252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25253         LDKChannelHandshakeLimits this_obj_conv;
25254         this_obj_conv.inner = (void*)(this_obj & (~1));
25255         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25257         ChannelHandshakeLimits_free(this_obj_conv);
25258 }
25259
25260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25261         LDKChannelHandshakeLimits this_ptr_conv;
25262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25263         this_ptr_conv.is_owned = false;
25264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25265         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
25266         return ret_conv;
25267 }
25268
25269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25270         LDKChannelHandshakeLimits this_ptr_conv;
25271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25272         this_ptr_conv.is_owned = false;
25273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25274         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
25275 }
25276
25277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25278         LDKChannelHandshakeLimits this_ptr_conv;
25279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25280         this_ptr_conv.is_owned = false;
25281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25282         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
25283         return ret_conv;
25284 }
25285
25286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25287         LDKChannelHandshakeLimits this_ptr_conv;
25288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25289         this_ptr_conv.is_owned = false;
25290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25291         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
25292 }
25293
25294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25295         LDKChannelHandshakeLimits this_ptr_conv;
25296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25297         this_ptr_conv.is_owned = false;
25298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25299         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
25300         return ret_conv;
25301 }
25302
25303 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) {
25304         LDKChannelHandshakeLimits this_ptr_conv;
25305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25306         this_ptr_conv.is_owned = false;
25307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25308         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
25309 }
25310
25311 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) {
25312         LDKChannelHandshakeLimits this_ptr_conv;
25313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25314         this_ptr_conv.is_owned = false;
25315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25316         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
25317         return ret_conv;
25318 }
25319
25320 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) {
25321         LDKChannelHandshakeLimits this_ptr_conv;
25322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25323         this_ptr_conv.is_owned = false;
25324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25325         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25326 }
25327
25328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25329         LDKChannelHandshakeLimits this_ptr_conv;
25330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25331         this_ptr_conv.is_owned = false;
25332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25333         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
25334         return ret_conv;
25335 }
25336
25337 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) {
25338         LDKChannelHandshakeLimits this_ptr_conv;
25339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25340         this_ptr_conv.is_owned = false;
25341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25342         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
25343 }
25344
25345 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25346         LDKChannelHandshakeLimits this_ptr_conv;
25347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25348         this_ptr_conv.is_owned = false;
25349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25350         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
25351         return ret_conv;
25352 }
25353
25354 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) {
25355         LDKChannelHandshakeLimits this_ptr_conv;
25356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25357         this_ptr_conv.is_owned = false;
25358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25359         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
25360 }
25361
25362 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25363         LDKChannelHandshakeLimits this_ptr_conv;
25364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25365         this_ptr_conv.is_owned = false;
25366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25367         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
25368         return ret_conv;
25369 }
25370
25371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25372         LDKChannelHandshakeLimits this_ptr_conv;
25373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25374         this_ptr_conv.is_owned = false;
25375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25376         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
25377 }
25378
25379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
25380         LDKChannelHandshakeLimits this_ptr_conv;
25381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25382         this_ptr_conv.is_owned = false;
25383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25384         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
25385         return ret_conv;
25386 }
25387
25388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25389         LDKChannelHandshakeLimits this_ptr_conv;
25390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25391         this_ptr_conv.is_owned = false;
25392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25393         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
25394 }
25395
25396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
25397         LDKChannelHandshakeLimits this_ptr_conv;
25398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25399         this_ptr_conv.is_owned = false;
25400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25401         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
25402         return ret_conv;
25403 }
25404
25405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25406         LDKChannelHandshakeLimits this_ptr_conv;
25407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25408         this_ptr_conv.is_owned = false;
25409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25410         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
25411 }
25412
25413 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25414         LDKChannelHandshakeLimits this_ptr_conv;
25415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25416         this_ptr_conv.is_owned = false;
25417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25418         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
25419         return ret_conv;
25420 }
25421
25422 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) {
25423         LDKChannelHandshakeLimits this_ptr_conv;
25424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25425         this_ptr_conv.is_owned = false;
25426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25427         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
25428 }
25429
25430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
25431         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
25432         int64_t ret_ref = 0;
25433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25436         ret_ref = (uintptr_t)ret_var.inner;
25437         if (ret_var.is_owned) {
25438                 ret_ref |= 1;
25439         }
25440         return ret_ref;
25441 }
25442
25443 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
25444         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
25445 int64_t ret_ref = 0;
25446 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25447 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25448 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25449 ret_ref = (uintptr_t)ret_var.inner;
25450 if (ret_var.is_owned) {
25451         ret_ref |= 1;
25452 }
25453         return ret_ref;
25454 }
25455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25456         LDKChannelHandshakeLimits arg_conv;
25457         arg_conv.inner = (void*)(arg & (~1));
25458         arg_conv.is_owned = false;
25459         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25460         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
25461         return ret_conv;
25462 }
25463
25464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25465         LDKChannelHandshakeLimits orig_conv;
25466         orig_conv.inner = (void*)(orig & (~1));
25467         orig_conv.is_owned = false;
25468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25469         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
25470         int64_t ret_ref = 0;
25471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25474         ret_ref = (uintptr_t)ret_var.inner;
25475         if (ret_var.is_owned) {
25476                 ret_ref |= 1;
25477         }
25478         return ret_ref;
25479 }
25480
25481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
25482         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
25483         int64_t ret_ref = 0;
25484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25487         ret_ref = (uintptr_t)ret_var.inner;
25488         if (ret_var.is_owned) {
25489                 ret_ref |= 1;
25490         }
25491         return ret_ref;
25492 }
25493
25494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25495         LDKChannelConfig this_obj_conv;
25496         this_obj_conv.inner = (void*)(this_obj & (~1));
25497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25499         ChannelConfig_free(this_obj_conv);
25500 }
25501
25502 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25503         LDKChannelConfig this_ptr_conv;
25504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25505         this_ptr_conv.is_owned = false;
25506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25507         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
25508         return ret_conv;
25509 }
25510
25511 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) {
25512         LDKChannelConfig this_ptr_conv;
25513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25514         this_ptr_conv.is_owned = false;
25515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25516         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
25517 }
25518
25519 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25520         LDKChannelConfig this_ptr_conv;
25521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25522         this_ptr_conv.is_owned = false;
25523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25524         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
25525         return ret_conv;
25526 }
25527
25528 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) {
25529         LDKChannelConfig this_ptr_conv;
25530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25531         this_ptr_conv.is_owned = false;
25532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25533         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
25534 }
25535
25536 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
25537         LDKChannelConfig this_ptr_conv;
25538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25539         this_ptr_conv.is_owned = false;
25540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25541         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
25542         return ret_conv;
25543 }
25544
25545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25546         LDKChannelConfig this_ptr_conv;
25547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25548         this_ptr_conv.is_owned = false;
25549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25550         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
25551 }
25552
25553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25554         LDKChannelConfig this_ptr_conv;
25555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25556         this_ptr_conv.is_owned = false;
25557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25558         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
25559         return ret_conv;
25560 }
25561
25562 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) {
25563         LDKChannelConfig this_ptr_conv;
25564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25565         this_ptr_conv.is_owned = false;
25566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25567         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
25568 }
25569
25570 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) {
25571         LDKChannelConfig this_ptr_conv;
25572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25573         this_ptr_conv.is_owned = false;
25574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25575         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
25576         return ret_conv;
25577 }
25578
25579 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) {
25580         LDKChannelConfig this_ptr_conv;
25581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25582         this_ptr_conv.is_owned = false;
25583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25584         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
25585 }
25586
25587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
25588         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
25589         int64_t ret_ref = 0;
25590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25593         ret_ref = (uintptr_t)ret_var.inner;
25594         if (ret_var.is_owned) {
25595                 ret_ref |= 1;
25596         }
25597         return ret_ref;
25598 }
25599
25600 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
25601         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
25602 int64_t ret_ref = 0;
25603 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25604 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25606 ret_ref = (uintptr_t)ret_var.inner;
25607 if (ret_var.is_owned) {
25608         ret_ref |= 1;
25609 }
25610         return ret_ref;
25611 }
25612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25613         LDKChannelConfig arg_conv;
25614         arg_conv.inner = (void*)(arg & (~1));
25615         arg_conv.is_owned = false;
25616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25617         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
25618         return ret_conv;
25619 }
25620
25621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25622         LDKChannelConfig orig_conv;
25623         orig_conv.inner = (void*)(orig & (~1));
25624         orig_conv.is_owned = false;
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25626         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
25627         int64_t ret_ref = 0;
25628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25631         ret_ref = (uintptr_t)ret_var.inner;
25632         if (ret_var.is_owned) {
25633                 ret_ref |= 1;
25634         }
25635         return ret_ref;
25636 }
25637
25638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
25639         LDKChannelConfig ret_var = ChannelConfig_default();
25640         int64_t ret_ref = 0;
25641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25644         ret_ref = (uintptr_t)ret_var.inner;
25645         if (ret_var.is_owned) {
25646                 ret_ref |= 1;
25647         }
25648         return ret_ref;
25649 }
25650
25651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
25652         LDKChannelConfig obj_conv;
25653         obj_conv.inner = (void*)(obj & (~1));
25654         obj_conv.is_owned = false;
25655         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25656         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
25657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25659         CVec_u8Z_free(ret_var);
25660         return ret_arr;
25661 }
25662
25663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25664         LDKu8slice ser_ref;
25665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25667         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
25668         *ret_conv = ChannelConfig_read(ser_ref);
25669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25670         return (int64_t)ret_conv;
25671 }
25672
25673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25674         LDKUserConfig this_obj_conv;
25675         this_obj_conv.inner = (void*)(this_obj & (~1));
25676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25678         UserConfig_free(this_obj_conv);
25679 }
25680
25681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25682         LDKUserConfig this_ptr_conv;
25683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25684         this_ptr_conv.is_owned = false;
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25686         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
25687         int64_t ret_ref = 0;
25688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25691         ret_ref = (uintptr_t)ret_var.inner;
25692         if (ret_var.is_owned) {
25693                 ret_ref |= 1;
25694         }
25695         return ret_ref;
25696 }
25697
25698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25699         LDKUserConfig this_ptr_conv;
25700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25701         this_ptr_conv.is_owned = false;
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25703         LDKChannelHandshakeConfig val_conv;
25704         val_conv.inner = (void*)(val & (~1));
25705         val_conv.is_owned = (val & 1) || (val == 0);
25706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25707         val_conv = ChannelHandshakeConfig_clone(&val_conv);
25708         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
25709 }
25710
25711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
25712         LDKUserConfig this_ptr_conv;
25713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25714         this_ptr_conv.is_owned = false;
25715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25716         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
25717         int64_t ret_ref = 0;
25718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25721         ret_ref = (uintptr_t)ret_var.inner;
25722         if (ret_var.is_owned) {
25723                 ret_ref |= 1;
25724         }
25725         return ret_ref;
25726 }
25727
25728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25729         LDKUserConfig this_ptr_conv;
25730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25731         this_ptr_conv.is_owned = false;
25732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25733         LDKChannelHandshakeLimits val_conv;
25734         val_conv.inner = (void*)(val & (~1));
25735         val_conv.is_owned = (val & 1) || (val == 0);
25736         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25737         val_conv = ChannelHandshakeLimits_clone(&val_conv);
25738         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
25739 }
25740
25741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25742         LDKUserConfig this_ptr_conv;
25743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25744         this_ptr_conv.is_owned = false;
25745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25746         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
25747         int64_t ret_ref = 0;
25748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25751         ret_ref = (uintptr_t)ret_var.inner;
25752         if (ret_var.is_owned) {
25753                 ret_ref |= 1;
25754         }
25755         return ret_ref;
25756 }
25757
25758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25759         LDKUserConfig this_ptr_conv;
25760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25761         this_ptr_conv.is_owned = false;
25762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25763         LDKChannelConfig val_conv;
25764         val_conv.inner = (void*)(val & (~1));
25765         val_conv.is_owned = (val & 1) || (val == 0);
25766         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25767         val_conv = ChannelConfig_clone(&val_conv);
25768         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
25769 }
25770
25771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25772         LDKUserConfig this_ptr_conv;
25773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25774         this_ptr_conv.is_owned = false;
25775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25776         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
25777         return ret_conv;
25778 }
25779
25780 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) {
25781         LDKUserConfig this_ptr_conv;
25782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25783         this_ptr_conv.is_owned = false;
25784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25785         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
25786 }
25787
25788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25789         LDKUserConfig this_ptr_conv;
25790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25791         this_ptr_conv.is_owned = false;
25792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25793         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
25794         return ret_conv;
25795 }
25796
25797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25798         LDKUserConfig this_ptr_conv;
25799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25800         this_ptr_conv.is_owned = false;
25801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25802         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
25803 }
25804
25805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25806         LDKUserConfig this_ptr_conv;
25807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25808         this_ptr_conv.is_owned = false;
25809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25810         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
25811         return ret_conv;
25812 }
25813
25814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25815         LDKUserConfig this_ptr_conv;
25816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25817         this_ptr_conv.is_owned = false;
25818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25819         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
25820 }
25821
25822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
25823         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
25824         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
25825         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
25826         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
25827         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
25828         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
25829         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
25830         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
25831         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
25832         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
25833         LDKChannelConfig channel_config_arg_conv;
25834         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
25835         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
25836         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
25837         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
25838         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
25839         int64_t ret_ref = 0;
25840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25843         ret_ref = (uintptr_t)ret_var.inner;
25844         if (ret_var.is_owned) {
25845                 ret_ref |= 1;
25846         }
25847         return ret_ref;
25848 }
25849
25850 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
25851         LDKUserConfig ret_var = UserConfig_clone(arg);
25852 int64_t ret_ref = 0;
25853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25856 ret_ref = (uintptr_t)ret_var.inner;
25857 if (ret_var.is_owned) {
25858         ret_ref |= 1;
25859 }
25860         return ret_ref;
25861 }
25862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25863         LDKUserConfig arg_conv;
25864         arg_conv.inner = (void*)(arg & (~1));
25865         arg_conv.is_owned = false;
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25867         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
25868         return ret_conv;
25869 }
25870
25871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25872         LDKUserConfig orig_conv;
25873         orig_conv.inner = (void*)(orig & (~1));
25874         orig_conv.is_owned = false;
25875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25876         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
25877         int64_t ret_ref = 0;
25878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25881         ret_ref = (uintptr_t)ret_var.inner;
25882         if (ret_var.is_owned) {
25883                 ret_ref |= 1;
25884         }
25885         return ret_ref;
25886 }
25887
25888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
25889         LDKUserConfig ret_var = UserConfig_default();
25890         int64_t ret_ref = 0;
25891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25894         ret_ref = (uintptr_t)ret_var.inner;
25895         if (ret_var.is_owned) {
25896                 ret_ref |= 1;
25897         }
25898         return ret_ref;
25899 }
25900
25901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25902         LDKBestBlock this_obj_conv;
25903         this_obj_conv.inner = (void*)(this_obj & (~1));
25904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25906         BestBlock_free(this_obj_conv);
25907 }
25908
25909 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
25910         LDKBestBlock ret_var = BestBlock_clone(arg);
25911 int64_t ret_ref = 0;
25912 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25913 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25914 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25915 ret_ref = (uintptr_t)ret_var.inner;
25916 if (ret_var.is_owned) {
25917         ret_ref |= 1;
25918 }
25919         return ret_ref;
25920 }
25921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25922         LDKBestBlock arg_conv;
25923         arg_conv.inner = (void*)(arg & (~1));
25924         arg_conv.is_owned = false;
25925         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25926         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
25927         return ret_conv;
25928 }
25929
25930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25931         LDKBestBlock orig_conv;
25932         orig_conv.inner = (void*)(orig & (~1));
25933         orig_conv.is_owned = false;
25934         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25935         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25936         int64_t ret_ref = 0;
25937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25940         ret_ref = (uintptr_t)ret_var.inner;
25941         if (ret_var.is_owned) {
25942                 ret_ref |= 1;
25943         }
25944         return ret_ref;
25945 }
25946
25947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25948         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25949         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
25950         int64_t ret_ref = 0;
25951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25954         ret_ref = (uintptr_t)ret_var.inner;
25955         if (ret_var.is_owned) {
25956                 ret_ref |= 1;
25957         }
25958         return ret_ref;
25959 }
25960
25961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25962         LDKThirtyTwoBytes block_hash_ref;
25963         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25964         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25965         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25966         int64_t ret_ref = 0;
25967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25970         ret_ref = (uintptr_t)ret_var.inner;
25971         if (ret_var.is_owned) {
25972                 ret_ref |= 1;
25973         }
25974         return ret_ref;
25975 }
25976
25977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25978         LDKBestBlock this_arg_conv;
25979         this_arg_conv.inner = (void*)(this_arg & (~1));
25980         this_arg_conv.is_owned = false;
25981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25982         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25983         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25984         return ret_arr;
25985 }
25986
25987 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25988         LDKBestBlock this_arg_conv;
25989         this_arg_conv.inner = (void*)(this_arg & (~1));
25990         this_arg_conv.is_owned = false;
25991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25992         int32_t ret_conv = BestBlock_height(&this_arg_conv);
25993         return ret_conv;
25994 }
25995
25996 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25997         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
25998         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25999         return ret_conv;
26000 }
26001
26002 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
26003         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
26004         return ret_conv;
26005 }
26006
26007 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
26008         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
26009         return ret_conv;
26010 }
26011
26012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26013         if ((this_ptr & 1) != 0) return;
26014         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26015         CHECK_ACCESS(this_ptr_ptr);
26016         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
26017         FREE((void*)this_ptr);
26018         Access_free(this_ptr_conv);
26019 }
26020
26021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26022         if ((this_ptr & 1) != 0) return;
26023         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26024         CHECK_ACCESS(this_ptr_ptr);
26025         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
26026         FREE((void*)this_ptr);
26027         Listen_free(this_ptr_conv);
26028 }
26029
26030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26031         if ((this_ptr & 1) != 0) return;
26032         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26033         CHECK_ACCESS(this_ptr_ptr);
26034         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
26035         FREE((void*)this_ptr);
26036         Confirm_free(this_ptr_conv);
26037 }
26038
26039 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26040         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
26041         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
26042         return ret_conv;
26043 }
26044
26045 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
26046         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
26047         return ret_conv;
26048 }
26049
26050 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
26051         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
26052         return ret_conv;
26053 }
26054
26055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26056         if ((this_ptr & 1) != 0) return;
26057         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26058         CHECK_ACCESS(this_ptr_ptr);
26059         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
26060         FREE((void*)this_ptr);
26061         Watch_free(this_ptr_conv);
26062 }
26063
26064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26065         if ((this_ptr & 1) != 0) return;
26066         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26067         CHECK_ACCESS(this_ptr_ptr);
26068         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
26069         FREE((void*)this_ptr);
26070         Filter_free(this_ptr_conv);
26071 }
26072
26073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26074         LDKWatchedOutput this_obj_conv;
26075         this_obj_conv.inner = (void*)(this_obj & (~1));
26076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26078         WatchedOutput_free(this_obj_conv);
26079 }
26080
26081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26082         LDKWatchedOutput this_ptr_conv;
26083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26084         this_ptr_conv.is_owned = false;
26085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26086         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26087         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
26088         return ret_arr;
26089 }
26090
26091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26092         LDKWatchedOutput this_ptr_conv;
26093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26094         this_ptr_conv.is_owned = false;
26095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26096         LDKThirtyTwoBytes val_ref;
26097         CHECK((*env)->GetArrayLength(env, val) == 32);
26098         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26099         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
26100 }
26101
26102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26103         LDKWatchedOutput this_ptr_conv;
26104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26105         this_ptr_conv.is_owned = false;
26106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26107         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
26108         int64_t ret_ref = 0;
26109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26112         ret_ref = (uintptr_t)ret_var.inner;
26113         if (ret_var.is_owned) {
26114                 ret_ref |= 1;
26115         }
26116         return ret_ref;
26117 }
26118
26119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26120         LDKWatchedOutput this_ptr_conv;
26121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26122         this_ptr_conv.is_owned = false;
26123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26124         LDKOutPoint val_conv;
26125         val_conv.inner = (void*)(val & (~1));
26126         val_conv.is_owned = (val & 1) || (val == 0);
26127         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26128         val_conv = OutPoint_clone(&val_conv);
26129         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
26130 }
26131
26132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26133         LDKWatchedOutput this_ptr_conv;
26134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26135         this_ptr_conv.is_owned = false;
26136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26137         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
26138         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26139         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26140         return ret_arr;
26141 }
26142
26143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26144         LDKWatchedOutput this_ptr_conv;
26145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26146         this_ptr_conv.is_owned = false;
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26148         LDKCVec_u8Z val_ref;
26149         val_ref.datalen = (*env)->GetArrayLength(env, val);
26150         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26151         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26152         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
26153 }
26154
26155 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) {
26156         LDKThirtyTwoBytes block_hash_arg_ref;
26157         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
26158         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
26159         LDKOutPoint outpoint_arg_conv;
26160         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26161         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26162         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26163         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26164         LDKCVec_u8Z script_pubkey_arg_ref;
26165         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
26166         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26167         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
26168         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
26169         int64_t ret_ref = 0;
26170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26173         ret_ref = (uintptr_t)ret_var.inner;
26174         if (ret_var.is_owned) {
26175                 ret_ref |= 1;
26176         }
26177         return ret_ref;
26178 }
26179
26180 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
26181         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
26182 int64_t ret_ref = 0;
26183 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26184 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26185 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26186 ret_ref = (uintptr_t)ret_var.inner;
26187 if (ret_var.is_owned) {
26188         ret_ref |= 1;
26189 }
26190         return ret_ref;
26191 }
26192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26193         LDKWatchedOutput arg_conv;
26194         arg_conv.inner = (void*)(arg & (~1));
26195         arg_conv.is_owned = false;
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26197         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
26198         return ret_conv;
26199 }
26200
26201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26202         LDKWatchedOutput orig_conv;
26203         orig_conv.inner = (void*)(orig & (~1));
26204         orig_conv.is_owned = false;
26205         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26206         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
26207         int64_t ret_ref = 0;
26208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26211         ret_ref = (uintptr_t)ret_var.inner;
26212         if (ret_var.is_owned) {
26213                 ret_ref |= 1;
26214         }
26215         return ret_ref;
26216 }
26217
26218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
26219         LDKWatchedOutput o_conv;
26220         o_conv.inner = (void*)(o & (~1));
26221         o_conv.is_owned = false;
26222         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26223         int64_t ret_conv = WatchedOutput_hash(&o_conv);
26224         return ret_conv;
26225 }
26226
26227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26228         if ((this_ptr & 1) != 0) return;
26229         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26230         CHECK_ACCESS(this_ptr_ptr);
26231         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
26232         FREE((void*)this_ptr);
26233         BroadcasterInterface_free(this_ptr_conv);
26234 }
26235
26236 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26237         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
26238         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
26239         return ret_conv;
26240 }
26241
26242 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
26243         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
26244         return ret_conv;
26245 }
26246
26247 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
26248         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
26249         return ret_conv;
26250 }
26251
26252 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
26253         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
26254         return ret_conv;
26255 }
26256
26257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26258         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
26259         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
26260         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
26261         return ret_conv;
26262 }
26263
26264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26265         if ((this_ptr & 1) != 0) return;
26266         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26267         CHECK_ACCESS(this_ptr_ptr);
26268         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
26269         FREE((void*)this_ptr);
26270         FeeEstimator_free(this_ptr_conv);
26271 }
26272
26273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26274         LDKMonitorUpdateId this_obj_conv;
26275         this_obj_conv.inner = (void*)(this_obj & (~1));
26276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26278         MonitorUpdateId_free(this_obj_conv);
26279 }
26280
26281 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
26282         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
26283 int64_t ret_ref = 0;
26284 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26285 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26286 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26287 ret_ref = (uintptr_t)ret_var.inner;
26288 if (ret_var.is_owned) {
26289         ret_ref |= 1;
26290 }
26291         return ret_ref;
26292 }
26293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26294         LDKMonitorUpdateId arg_conv;
26295         arg_conv.inner = (void*)(arg & (~1));
26296         arg_conv.is_owned = false;
26297         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26298         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
26299         return ret_conv;
26300 }
26301
26302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26303         LDKMonitorUpdateId orig_conv;
26304         orig_conv.inner = (void*)(orig & (~1));
26305         orig_conv.is_owned = false;
26306         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26307         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
26308         int64_t ret_ref = 0;
26309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26312         ret_ref = (uintptr_t)ret_var.inner;
26313         if (ret_var.is_owned) {
26314                 ret_ref |= 1;
26315         }
26316         return ret_ref;
26317 }
26318
26319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
26320         LDKMonitorUpdateId o_conv;
26321         o_conv.inner = (void*)(o & (~1));
26322         o_conv.is_owned = false;
26323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26324         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
26325         return ret_conv;
26326 }
26327
26328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26329         LDKMonitorUpdateId a_conv;
26330         a_conv.inner = (void*)(a & (~1));
26331         a_conv.is_owned = false;
26332         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26333         LDKMonitorUpdateId b_conv;
26334         b_conv.inner = (void*)(b & (~1));
26335         b_conv.is_owned = false;
26336         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26337         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
26338         return ret_conv;
26339 }
26340
26341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26342         if ((this_ptr & 1) != 0) return;
26343         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26344         CHECK_ACCESS(this_ptr_ptr);
26345         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
26346         FREE((void*)this_ptr);
26347         Persist_free(this_ptr_conv);
26348 }
26349
26350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26351         LDKLockedChannelMonitor this_obj_conv;
26352         this_obj_conv.inner = (void*)(this_obj & (~1));
26353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26355         LockedChannelMonitor_free(this_obj_conv);
26356 }
26357
26358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26359         LDKChainMonitor this_obj_conv;
26360         this_obj_conv.inner = (void*)(this_obj & (~1));
26361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26363         ChainMonitor_free(this_obj_conv);
26364 }
26365
26366 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) {
26367         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
26368         CHECK_ACCESS(chain_source_ptr);
26369         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
26370         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
26371         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
26372                 // Manually implement clone for Java trait instances
26373                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
26374                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26375                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
26376                 }
26377         }
26378         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26379         CHECK_ACCESS(broadcaster_ptr);
26380         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26381         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26382                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26383                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26384         }
26385         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26386         CHECK_ACCESS(logger_ptr);
26387         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26388         if (logger_conv.free == LDKLogger_JCalls_free) {
26389                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26390                 LDKLogger_JCalls_cloned(&logger_conv);
26391         }
26392         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
26393         CHECK_ACCESS(feeest_ptr);
26394         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
26395         if (feeest_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(&feeest_conv);
26398         }
26399         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
26400         CHECK_ACCESS(persister_ptr);
26401         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
26402         if (persister_conv.free == LDKPersist_JCalls_free) {
26403                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26404                 LDKPersist_JCalls_cloned(&persister_conv);
26405         }
26406         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
26407         int64_t ret_ref = 0;
26408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26411         ret_ref = (uintptr_t)ret_var.inner;
26412         if (ret_var.is_owned) {
26413                 ret_ref |= 1;
26414         }
26415         return ret_ref;
26416 }
26417
26418 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) {
26419         LDKChainMonitor this_arg_conv;
26420         this_arg_conv.inner = (void*)(this_arg & (~1));
26421         this_arg_conv.is_owned = false;
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26423         LDKCVec_ChannelDetailsZ ignored_channels_constr;
26424         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
26425         if (ignored_channels_constr.datalen > 0)
26426                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26427         else
26428                 ignored_channels_constr.data = NULL;
26429         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
26430         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
26431                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
26432                 LDKChannelDetails ignored_channels_conv_16_conv;
26433                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
26434                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
26435                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
26436                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
26437                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
26438         }
26439         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
26440         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
26441         int64_tArray ret_arr = NULL;
26442         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26443         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26444         for (size_t j = 0; j < ret_var.datalen; j++) {
26445                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26446                 *ret_conv_9_copy = ret_var.data[j];
26447                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26448                 ret_arr_ptr[j] = ret_conv_9_ref;
26449         }
26450         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26451         FREE(ret_var.data);
26452         return ret_arr;
26453 }
26454
26455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
26456         LDKChainMonitor this_arg_conv;
26457         this_arg_conv.inner = (void*)(this_arg & (~1));
26458         this_arg_conv.is_owned = false;
26459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26460         LDKOutPoint funding_txo_conv;
26461         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26462         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26463         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26464         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26465         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26466         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
26467         return (int64_t)ret_conv;
26468 }
26469
26470 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
26471         LDKChainMonitor this_arg_conv;
26472         this_arg_conv.inner = (void*)(this_arg & (~1));
26473         this_arg_conv.is_owned = false;
26474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26475         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
26476         int64_tArray ret_arr = NULL;
26477         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26478         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26479         for (size_t k = 0; k < ret_var.datalen; k++) {
26480                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
26481                 int64_t ret_conv_10_ref = 0;
26482                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26483                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26484                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
26485                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
26486                 if (ret_conv_10_var.is_owned) {
26487                         ret_conv_10_ref |= 1;
26488                 }
26489                 ret_arr_ptr[k] = ret_conv_10_ref;
26490         }
26491         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26492         FREE(ret_var.data);
26493         return ret_arr;
26494 }
26495
26496 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) {
26497         LDKChainMonitor this_arg_conv;
26498         this_arg_conv.inner = (void*)(this_arg & (~1));
26499         this_arg_conv.is_owned = false;
26500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26501         LDKOutPoint funding_txo_conv;
26502         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26503         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26504         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26505         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26506         LDKMonitorUpdateId completed_update_id_conv;
26507         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
26508         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
26509         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
26510         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
26511         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26512         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
26513         return (int64_t)ret_conv;
26514 }
26515
26516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
26517         LDKChainMonitor this_arg_conv;
26518         this_arg_conv.inner = (void*)(this_arg & (~1));
26519         this_arg_conv.is_owned = false;
26520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26521         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
26522         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
26523         return (int64_t)ret_ret;
26524 }
26525
26526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
26527         LDKChainMonitor this_arg_conv;
26528         this_arg_conv.inner = (void*)(this_arg & (~1));
26529         this_arg_conv.is_owned = false;
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26531         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
26532         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
26533         return (int64_t)ret_ret;
26534 }
26535
26536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26537         LDKChainMonitor this_arg_conv;
26538         this_arg_conv.inner = (void*)(this_arg & (~1));
26539         this_arg_conv.is_owned = false;
26540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26541         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
26542         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
26543         return (int64_t)ret_ret;
26544 }
26545
26546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
26547         LDKChainMonitor this_arg_conv;
26548         this_arg_conv.inner = (void*)(this_arg & (~1));
26549         this_arg_conv.is_owned = false;
26550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26551         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
26552         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
26553         return (int64_t)ret_ret;
26554 }
26555
26556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26557         LDKChannelMonitorUpdate this_obj_conv;
26558         this_obj_conv.inner = (void*)(this_obj & (~1));
26559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26561         ChannelMonitorUpdate_free(this_obj_conv);
26562 }
26563
26564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26565         LDKChannelMonitorUpdate this_ptr_conv;
26566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26567         this_ptr_conv.is_owned = false;
26568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26569         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
26570         return ret_conv;
26571 }
26572
26573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26574         LDKChannelMonitorUpdate this_ptr_conv;
26575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26576         this_ptr_conv.is_owned = false;
26577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26578         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
26579 }
26580
26581 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
26582         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
26583 int64_t ret_ref = 0;
26584 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26585 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26586 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26587 ret_ref = (uintptr_t)ret_var.inner;
26588 if (ret_var.is_owned) {
26589         ret_ref |= 1;
26590 }
26591         return ret_ref;
26592 }
26593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26594         LDKChannelMonitorUpdate arg_conv;
26595         arg_conv.inner = (void*)(arg & (~1));
26596         arg_conv.is_owned = false;
26597         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26598         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
26599         return ret_conv;
26600 }
26601
26602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26603         LDKChannelMonitorUpdate orig_conv;
26604         orig_conv.inner = (void*)(orig & (~1));
26605         orig_conv.is_owned = false;
26606         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26607         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
26608         int64_t ret_ref = 0;
26609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26612         ret_ref = (uintptr_t)ret_var.inner;
26613         if (ret_var.is_owned) {
26614                 ret_ref |= 1;
26615         }
26616         return ret_ref;
26617 }
26618
26619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26620         LDKChannelMonitorUpdate obj_conv;
26621         obj_conv.inner = (void*)(obj & (~1));
26622         obj_conv.is_owned = false;
26623         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26624         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
26625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26627         CVec_u8Z_free(ret_var);
26628         return ret_arr;
26629 }
26630
26631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26632         LDKu8slice ser_ref;
26633         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26634         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26635         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
26636         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
26637         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26638         return (int64_t)ret_conv;
26639 }
26640
26641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26642         if ((this_ptr & 1) != 0) return;
26643         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26644         CHECK_ACCESS(this_ptr_ptr);
26645         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
26646         FREE((void*)this_ptr);
26647         MonitorEvent_free(this_ptr_conv);
26648 }
26649
26650 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
26651         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26652         *ret_copy = MonitorEvent_clone(arg);
26653 int64_t ret_ref = (uintptr_t)ret_copy;
26654         return ret_ref;
26655 }
26656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26657         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
26658         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
26659         return ret_conv;
26660 }
26661
26662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26663         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
26664         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26665         *ret_copy = MonitorEvent_clone(orig_conv);
26666         int64_t ret_ref = (uintptr_t)ret_copy;
26667         return ret_ref;
26668 }
26669
26670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
26671         LDKHTLCUpdate a_conv;
26672         a_conv.inner = (void*)(a & (~1));
26673         a_conv.is_owned = (a & 1) || (a == 0);
26674         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26675         a_conv = HTLCUpdate_clone(&a_conv);
26676         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26677         *ret_copy = MonitorEvent_htlcevent(a_conv);
26678         int64_t ret_ref = (uintptr_t)ret_copy;
26679         return ret_ref;
26680 }
26681
26682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
26683         LDKOutPoint a_conv;
26684         a_conv.inner = (void*)(a & (~1));
26685         a_conv.is_owned = (a & 1) || (a == 0);
26686         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26687         a_conv = OutPoint_clone(&a_conv);
26688         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26689         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
26690         int64_t ret_ref = (uintptr_t)ret_copy;
26691         return ret_ref;
26692 }
26693
26694 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) {
26695         LDKOutPoint funding_txo_conv;
26696         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26697         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26698         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26699         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26700         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26701         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
26702         int64_t ret_ref = (uintptr_t)ret_copy;
26703         return ret_ref;
26704 }
26705
26706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
26707         LDKOutPoint a_conv;
26708         a_conv.inner = (void*)(a & (~1));
26709         a_conv.is_owned = (a & 1) || (a == 0);
26710         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26711         a_conv = OutPoint_clone(&a_conv);
26712         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26713         *ret_copy = MonitorEvent_update_failed(a_conv);
26714         int64_t ret_ref = (uintptr_t)ret_copy;
26715         return ret_ref;
26716 }
26717
26718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
26719         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
26720         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
26721         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26722         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26723         CVec_u8Z_free(ret_var);
26724         return ret_arr;
26725 }
26726
26727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26728         LDKu8slice ser_ref;
26729         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26730         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26731         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
26732         *ret_conv = MonitorEvent_read(ser_ref);
26733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26734         return (int64_t)ret_conv;
26735 }
26736
26737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26738         LDKHTLCUpdate this_obj_conv;
26739         this_obj_conv.inner = (void*)(this_obj & (~1));
26740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26742         HTLCUpdate_free(this_obj_conv);
26743 }
26744
26745 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
26746         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
26747 int64_t ret_ref = 0;
26748 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26749 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26750 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26751 ret_ref = (uintptr_t)ret_var.inner;
26752 if (ret_var.is_owned) {
26753         ret_ref |= 1;
26754 }
26755         return ret_ref;
26756 }
26757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26758         LDKHTLCUpdate arg_conv;
26759         arg_conv.inner = (void*)(arg & (~1));
26760         arg_conv.is_owned = false;
26761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26762         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
26763         return ret_conv;
26764 }
26765
26766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26767         LDKHTLCUpdate orig_conv;
26768         orig_conv.inner = (void*)(orig & (~1));
26769         orig_conv.is_owned = false;
26770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26771         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
26772         int64_t ret_ref = 0;
26773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26776         ret_ref = (uintptr_t)ret_var.inner;
26777         if (ret_var.is_owned) {
26778                 ret_ref |= 1;
26779         }
26780         return ret_ref;
26781 }
26782
26783 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26784         LDKHTLCUpdate obj_conv;
26785         obj_conv.inner = (void*)(obj & (~1));
26786         obj_conv.is_owned = false;
26787         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26788         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
26789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26791         CVec_u8Z_free(ret_var);
26792         return ret_arr;
26793 }
26794
26795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26796         LDKu8slice ser_ref;
26797         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26798         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26799         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
26800         *ret_conv = HTLCUpdate_read(ser_ref);
26801         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26802         return (int64_t)ret_conv;
26803 }
26804
26805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26806         if ((this_ptr & 1) != 0) return;
26807         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26808         CHECK_ACCESS(this_ptr_ptr);
26809         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
26810         FREE((void*)this_ptr);
26811         Balance_free(this_ptr_conv);
26812 }
26813
26814 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
26815         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26816         *ret_copy = Balance_clone(arg);
26817 int64_t ret_ref = (uintptr_t)ret_copy;
26818         return ret_ref;
26819 }
26820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26821         LDKBalance* arg_conv = (LDKBalance*)arg;
26822         int64_t ret_conv = Balance_clone_ptr(arg_conv);
26823         return ret_conv;
26824 }
26825
26826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26827         LDKBalance* orig_conv = (LDKBalance*)orig;
26828         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26829         *ret_copy = Balance_clone(orig_conv);
26830         int64_t ret_ref = (uintptr_t)ret_copy;
26831         return ret_ref;
26832 }
26833
26834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
26835         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26836         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
26837         int64_t ret_ref = (uintptr_t)ret_copy;
26838         return ret_ref;
26839 }
26840
26841 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) {
26842         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26843         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
26844         int64_t ret_ref = (uintptr_t)ret_copy;
26845         return ret_ref;
26846 }
26847
26848 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) {
26849         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26850         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
26851         int64_t ret_ref = (uintptr_t)ret_copy;
26852         return ret_ref;
26853 }
26854
26855 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) {
26856         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26857         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
26858         int64_t ret_ref = (uintptr_t)ret_copy;
26859         return ret_ref;
26860 }
26861
26862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26863         LDKBalance* a_conv = (LDKBalance*)a;
26864         LDKBalance* b_conv = (LDKBalance*)b;
26865         jboolean ret_conv = Balance_eq(a_conv, b_conv);
26866         return ret_conv;
26867 }
26868
26869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26870         LDKChannelMonitor this_obj_conv;
26871         this_obj_conv.inner = (void*)(this_obj & (~1));
26872         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26874         ChannelMonitor_free(this_obj_conv);
26875 }
26876
26877 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
26878         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
26879 int64_t ret_ref = 0;
26880 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26881 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26882 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26883 ret_ref = (uintptr_t)ret_var.inner;
26884 if (ret_var.is_owned) {
26885         ret_ref |= 1;
26886 }
26887         return ret_ref;
26888 }
26889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26890         LDKChannelMonitor arg_conv;
26891         arg_conv.inner = (void*)(arg & (~1));
26892         arg_conv.is_owned = false;
26893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26894         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
26895         return ret_conv;
26896 }
26897
26898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26899         LDKChannelMonitor orig_conv;
26900         orig_conv.inner = (void*)(orig & (~1));
26901         orig_conv.is_owned = false;
26902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26903         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
26904         int64_t ret_ref = 0;
26905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26908         ret_ref = (uintptr_t)ret_var.inner;
26909         if (ret_var.is_owned) {
26910                 ret_ref |= 1;
26911         }
26912         return ret_ref;
26913 }
26914
26915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26916         LDKChannelMonitor obj_conv;
26917         obj_conv.inner = (void*)(obj & (~1));
26918         obj_conv.is_owned = false;
26919         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26920         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
26921         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26922         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26923         CVec_u8Z_free(ret_var);
26924         return ret_arr;
26925 }
26926
26927 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) {
26928         LDKChannelMonitor this_arg_conv;
26929         this_arg_conv.inner = (void*)(this_arg & (~1));
26930         this_arg_conv.is_owned = false;
26931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26932         LDKChannelMonitorUpdate updates_conv;
26933         updates_conv.inner = (void*)(updates & (~1));
26934         updates_conv.is_owned = false;
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26936         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26937         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
26938         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26939         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26940         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
26941         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
26942         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26943         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26944         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26945         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26946         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26947         return (int64_t)ret_conv;
26948 }
26949
26950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26951         LDKChannelMonitor this_arg_conv;
26952         this_arg_conv.inner = (void*)(this_arg & (~1));
26953         this_arg_conv.is_owned = false;
26954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26955         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26956         return ret_conv;
26957 }
26958
26959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26960         LDKChannelMonitor this_arg_conv;
26961         this_arg_conv.inner = (void*)(this_arg & (~1));
26962         this_arg_conv.is_owned = false;
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26964         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26965         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26966         return ((int64_t)ret_conv);
26967 }
26968
26969 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26970         LDKChannelMonitor this_arg_conv;
26971         this_arg_conv.inner = (void*)(this_arg & (~1));
26972         this_arg_conv.is_owned = false;
26973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26974         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26975         int64_tArray ret_arr = NULL;
26976         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26977         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26978         for (size_t o = 0; o < ret_var.datalen; o++) {
26979                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26980                 *ret_conv_40_conv = ret_var.data[o];
26981                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
26982         }
26983         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26984         FREE(ret_var.data);
26985         return ret_arr;
26986 }
26987
26988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26989         LDKChannelMonitor this_arg_conv;
26990         this_arg_conv.inner = (void*)(this_arg & (~1));
26991         this_arg_conv.is_owned = false;
26992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26993         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
26994         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
26995         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26996         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26997 }
26998
26999 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27000         LDKChannelMonitor this_arg_conv;
27001         this_arg_conv.inner = (void*)(this_arg & (~1));
27002         this_arg_conv.is_owned = false;
27003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27004         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
27005         int64_tArray ret_arr = NULL;
27006         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27007         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27008         for (size_t o = 0; o < ret_var.datalen; o++) {
27009                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27010                 *ret_conv_14_copy = ret_var.data[o];
27011                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
27012                 ret_arr_ptr[o] = ret_conv_14_ref;
27013         }
27014         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27015         FREE(ret_var.data);
27016         return ret_arr;
27017 }
27018
27019 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27020         LDKChannelMonitor this_arg_conv;
27021         this_arg_conv.inner = (void*)(this_arg & (~1));
27022         this_arg_conv.is_owned = false;
27023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27024         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
27025         int64_tArray ret_arr = NULL;
27026         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27027         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27028         for (size_t h = 0; h < ret_var.datalen; h++) {
27029                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
27030                 *ret_conv_7_copy = ret_var.data[h];
27031                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
27032                 ret_arr_ptr[h] = ret_conv_7_ref;
27033         }
27034         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27035         FREE(ret_var.data);
27036         return ret_arr;
27037 }
27038
27039 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) {
27040         LDKChannelMonitor this_arg_conv;
27041         this_arg_conv.inner = (void*)(this_arg & (~1));
27042         this_arg_conv.is_owned = false;
27043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27044         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27045         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27046         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27047         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
27048         jobjectArray ret_arr = NULL;
27049         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27050         ;
27051         for (size_t i = 0; i < ret_var.datalen; i++) {
27052                 LDKTransaction ret_conv_8_var = ret_var.data[i];
27053                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
27054                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
27055                 Transaction_free(ret_conv_8_var);
27056                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27057         }
27058         
27059         FREE(ret_var.data);
27060         return ret_arr;
27061 }
27062
27063 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) {
27064         LDKChannelMonitor this_arg_conv;
27065         this_arg_conv.inner = (void*)(this_arg & (~1));
27066         this_arg_conv.is_owned = false;
27067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27068         unsigned char header_arr[80];
27069         CHECK((*env)->GetArrayLength(env, header) == 80);
27070         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27071         unsigned char (*header_ref)[80] = &header_arr;
27072         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27073         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27074         if (txdata_constr.datalen > 0)
27075                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27076         else
27077                 txdata_constr.data = NULL;
27078         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27079         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27080                 int64_t txdata_conv_28 = txdata_vals[c];
27081                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27082                 CHECK_ACCESS(txdata_conv_28_ptr);
27083                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27084                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27085                 txdata_constr.data[c] = txdata_conv_28_conv;
27086         }
27087         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27088         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27089         CHECK_ACCESS(broadcaster_ptr);
27090         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27091         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27092                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27093                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27094         }
27095         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27096         CHECK_ACCESS(fee_estimator_ptr);
27097         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27098         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27100                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27101         }
27102         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27103         CHECK_ACCESS(logger_ptr);
27104         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27105         if (logger_conv.free == LDKLogger_JCalls_free) {
27106                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27107                 LDKLogger_JCalls_cloned(&logger_conv);
27108         }
27109         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);
27110         int64_tArray ret_arr = NULL;
27111         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27112         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27113         for (size_t n = 0; n < ret_var.datalen; n++) {
27114                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27115                 *ret_conv_39_conv = ret_var.data[n];
27116                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27117         }
27118         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27119         FREE(ret_var.data);
27120         return ret_arr;
27121 }
27122
27123 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) {
27124         LDKChannelMonitor this_arg_conv;
27125         this_arg_conv.inner = (void*)(this_arg & (~1));
27126         this_arg_conv.is_owned = false;
27127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27128         unsigned char header_arr[80];
27129         CHECK((*env)->GetArrayLength(env, header) == 80);
27130         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27131         unsigned char (*header_ref)[80] = &header_arr;
27132         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27133         CHECK_ACCESS(broadcaster_ptr);
27134         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27135         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27136                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27137                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27138         }
27139         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27140         CHECK_ACCESS(fee_estimator_ptr);
27141         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27142         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27143                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27144                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27145         }
27146         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27147         CHECK_ACCESS(logger_ptr);
27148         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27149         if (logger_conv.free == LDKLogger_JCalls_free) {
27150                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27151                 LDKLogger_JCalls_cloned(&logger_conv);
27152         }
27153         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27154 }
27155
27156 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) {
27157         LDKChannelMonitor this_arg_conv;
27158         this_arg_conv.inner = (void*)(this_arg & (~1));
27159         this_arg_conv.is_owned = false;
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27161         unsigned char header_arr[80];
27162         CHECK((*env)->GetArrayLength(env, header) == 80);
27163         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27164         unsigned char (*header_ref)[80] = &header_arr;
27165         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27166         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27167         if (txdata_constr.datalen > 0)
27168                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27169         else
27170                 txdata_constr.data = NULL;
27171         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27172         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27173                 int64_t txdata_conv_28 = txdata_vals[c];
27174                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27175                 CHECK_ACCESS(txdata_conv_28_ptr);
27176                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27177                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27178                 txdata_constr.data[c] = txdata_conv_28_conv;
27179         }
27180         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27181         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27182         CHECK_ACCESS(broadcaster_ptr);
27183         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27184         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27185                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27186                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27187         }
27188         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27189         CHECK_ACCESS(fee_estimator_ptr);
27190         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27191         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27193                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27194         }
27195         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27196         CHECK_ACCESS(logger_ptr);
27197         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27198         if (logger_conv.free == LDKLogger_JCalls_free) {
27199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27200                 LDKLogger_JCalls_cloned(&logger_conv);
27201         }
27202         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);
27203         int64_tArray ret_arr = NULL;
27204         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27205         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27206         for (size_t n = 0; n < ret_var.datalen; n++) {
27207                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27208                 *ret_conv_39_conv = ret_var.data[n];
27209                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27210         }
27211         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27212         FREE(ret_var.data);
27213         return ret_arr;
27214 }
27215
27216 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) {
27217         LDKChannelMonitor this_arg_conv;
27218         this_arg_conv.inner = (void*)(this_arg & (~1));
27219         this_arg_conv.is_owned = false;
27220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27221         unsigned char txid_arr[32];
27222         CHECK((*env)->GetArrayLength(env, txid) == 32);
27223         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
27224         unsigned char (*txid_ref)[32] = &txid_arr;
27225         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27226         CHECK_ACCESS(broadcaster_ptr);
27227         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27228         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27229                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27230                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27231         }
27232         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27233         CHECK_ACCESS(fee_estimator_ptr);
27234         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27235         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27237                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27238         }
27239         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27240         CHECK_ACCESS(logger_ptr);
27241         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27242         if (logger_conv.free == LDKLogger_JCalls_free) {
27243                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27244                 LDKLogger_JCalls_cloned(&logger_conv);
27245         }
27246         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
27247 }
27248
27249 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) {
27250         LDKChannelMonitor this_arg_conv;
27251         this_arg_conv.inner = (void*)(this_arg & (~1));
27252         this_arg_conv.is_owned = false;
27253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27254         unsigned char header_arr[80];
27255         CHECK((*env)->GetArrayLength(env, header) == 80);
27256         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27257         unsigned char (*header_ref)[80] = &header_arr;
27258         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27259         CHECK_ACCESS(broadcaster_ptr);
27260         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27261         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27262                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27263                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27264         }
27265         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27266         CHECK_ACCESS(fee_estimator_ptr);
27267         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27268         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27269                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27270                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27271         }
27272         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27273         CHECK_ACCESS(logger_ptr);
27274         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27275         if (logger_conv.free == LDKLogger_JCalls_free) {
27276                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27277                 LDKLogger_JCalls_cloned(&logger_conv);
27278         }
27279         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27280         int64_tArray ret_arr = NULL;
27281         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27282         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27283         for (size_t n = 0; n < ret_var.datalen; n++) {
27284                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27285                 *ret_conv_39_conv = ret_var.data[n];
27286                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27287         }
27288         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27289         FREE(ret_var.data);
27290         return ret_arr;
27291 }
27292
27293 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
27294         LDKChannelMonitor this_arg_conv;
27295         this_arg_conv.inner = (void*)(this_arg & (~1));
27296         this_arg_conv.is_owned = false;
27297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27298         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
27299         jobjectArray ret_arr = NULL;
27300         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27301         ;
27302         for (size_t i = 0; i < ret_var.datalen; i++) {
27303                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
27304                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
27305                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27306         }
27307         
27308         FREE(ret_var.data);
27309         return ret_arr;
27310 }
27311
27312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27313         LDKChannelMonitor this_arg_conv;
27314         this_arg_conv.inner = (void*)(this_arg & (~1));
27315         this_arg_conv.is_owned = false;
27316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27317         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
27318         int64_t ret_ref = 0;
27319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27322         ret_ref = (uintptr_t)ret_var.inner;
27323         if (ret_var.is_owned) {
27324                 ret_ref |= 1;
27325         }
27326         return ret_ref;
27327 }
27328
27329 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
27330         LDKChannelMonitor this_arg_conv;
27331         this_arg_conv.inner = (void*)(this_arg & (~1));
27332         this_arg_conv.is_owned = false;
27333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27334         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
27335         int64_tArray ret_arr = NULL;
27336         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27337         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27338         for (size_t j = 0; j < ret_var.datalen; j++) {
27339                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27340                 *ret_conv_9_copy = ret_var.data[j];
27341                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
27342                 ret_arr_ptr[j] = ret_conv_9_ref;
27343         }
27344         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27345         FREE(ret_var.data);
27346         return ret_arr;
27347 }
27348
27349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
27350         LDKu8slice ser_ref;
27351         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27352         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27353         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27354         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27355         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
27356         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
27357         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
27358         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27359         return (int64_t)ret_conv;
27360 }
27361
27362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27363         LDKOutPoint this_obj_conv;
27364         this_obj_conv.inner = (void*)(this_obj & (~1));
27365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27367         OutPoint_free(this_obj_conv);
27368 }
27369
27370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
27371         LDKOutPoint this_ptr_conv;
27372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27373         this_ptr_conv.is_owned = false;
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27375         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
27377         return ret_arr;
27378 }
27379
27380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27381         LDKOutPoint this_ptr_conv;
27382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27383         this_ptr_conv.is_owned = false;
27384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27385         LDKThirtyTwoBytes val_ref;
27386         CHECK((*env)->GetArrayLength(env, val) == 32);
27387         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27388         OutPoint_set_txid(&this_ptr_conv, val_ref);
27389 }
27390
27391 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
27392         LDKOutPoint this_ptr_conv;
27393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27394         this_ptr_conv.is_owned = false;
27395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27396         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
27397         return ret_conv;
27398 }
27399
27400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27401         LDKOutPoint this_ptr_conv;
27402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27403         this_ptr_conv.is_owned = false;
27404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27405         OutPoint_set_index(&this_ptr_conv, val);
27406 }
27407
27408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
27409         LDKThirtyTwoBytes txid_arg_ref;
27410         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
27411         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
27412         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
27413         int64_t ret_ref = 0;
27414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27417         ret_ref = (uintptr_t)ret_var.inner;
27418         if (ret_var.is_owned) {
27419                 ret_ref |= 1;
27420         }
27421         return ret_ref;
27422 }
27423
27424 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
27425         LDKOutPoint ret_var = OutPoint_clone(arg);
27426 int64_t ret_ref = 0;
27427 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27428 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27429 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27430 ret_ref = (uintptr_t)ret_var.inner;
27431 if (ret_var.is_owned) {
27432         ret_ref |= 1;
27433 }
27434         return ret_ref;
27435 }
27436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27437         LDKOutPoint arg_conv;
27438         arg_conv.inner = (void*)(arg & (~1));
27439         arg_conv.is_owned = false;
27440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27441         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
27442         return ret_conv;
27443 }
27444
27445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27446         LDKOutPoint orig_conv;
27447         orig_conv.inner = (void*)(orig & (~1));
27448         orig_conv.is_owned = false;
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27450         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
27451         int64_t ret_ref = 0;
27452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27455         ret_ref = (uintptr_t)ret_var.inner;
27456         if (ret_var.is_owned) {
27457                 ret_ref |= 1;
27458         }
27459         return ret_ref;
27460 }
27461
27462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27463         LDKOutPoint a_conv;
27464         a_conv.inner = (void*)(a & (~1));
27465         a_conv.is_owned = false;
27466         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27467         LDKOutPoint b_conv;
27468         b_conv.inner = (void*)(b & (~1));
27469         b_conv.is_owned = false;
27470         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27471         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
27472         return ret_conv;
27473 }
27474
27475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
27476         LDKOutPoint o_conv;
27477         o_conv.inner = (void*)(o & (~1));
27478         o_conv.is_owned = false;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27480         int64_t ret_conv = OutPoint_hash(&o_conv);
27481         return ret_conv;
27482 }
27483
27484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27485         LDKOutPoint this_arg_conv;
27486         this_arg_conv.inner = (void*)(this_arg & (~1));
27487         this_arg_conv.is_owned = false;
27488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27489         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27490         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
27491         return ret_arr;
27492 }
27493
27494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
27495         LDKOutPoint obj_conv;
27496         obj_conv.inner = (void*)(obj & (~1));
27497         obj_conv.is_owned = false;
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27499         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
27500         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27501         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27502         CVec_u8Z_free(ret_var);
27503         return ret_arr;
27504 }
27505
27506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27507         LDKu8slice ser_ref;
27508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27510         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
27511         *ret_conv = OutPoint_read(ser_ref);
27512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27513         return (int64_t)ret_conv;
27514 }
27515
27516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27517         LDKDelayedPaymentOutputDescriptor this_obj_conv;
27518         this_obj_conv.inner = (void*)(this_obj & (~1));
27519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27521         DelayedPaymentOutputDescriptor_free(this_obj_conv);
27522 }
27523
27524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27525         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27527         this_ptr_conv.is_owned = false;
27528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27529         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
27530         int64_t ret_ref = 0;
27531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27534         ret_ref = (uintptr_t)ret_var.inner;
27535         if (ret_var.is_owned) {
27536                 ret_ref |= 1;
27537         }
27538         return ret_ref;
27539 }
27540
27541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27542         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27544         this_ptr_conv.is_owned = false;
27545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27546         LDKOutPoint val_conv;
27547         val_conv.inner = (void*)(val & (~1));
27548         val_conv.is_owned = (val & 1) || (val == 0);
27549         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27550         val_conv = OutPoint_clone(&val_conv);
27551         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27552 }
27553
27554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27555         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27557         this_ptr_conv.is_owned = false;
27558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27559         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
27561         return ret_arr;
27562 }
27563
27564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27565         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27567         this_ptr_conv.is_owned = false;
27568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27569         LDKPublicKey val_ref;
27570         CHECK((*env)->GetArrayLength(env, val) == 33);
27571         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27572         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
27573 }
27574
27575 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27576         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27578         this_ptr_conv.is_owned = false;
27579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27580         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
27581         return ret_conv;
27582 }
27583
27584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27585         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27587         this_ptr_conv.is_owned = false;
27588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27589         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
27590 }
27591
27592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27593         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27595         this_ptr_conv.is_owned = false;
27596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27597         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27598         CHECK_ACCESS(val_ptr);
27599         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27600         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
27601         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27602 }
27603
27604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27605         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27607         this_ptr_conv.is_owned = false;
27608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27609         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27610         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
27611         return ret_arr;
27612 }
27613
27614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27615         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27617         this_ptr_conv.is_owned = false;
27618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27619         LDKPublicKey val_ref;
27620         CHECK((*env)->GetArrayLength(env, val) == 33);
27621         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27622         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
27623 }
27624
27625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27626         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27628         this_ptr_conv.is_owned = false;
27629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27630         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27631         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27632         return ret_arr;
27633 }
27634
27635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27636         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27638         this_ptr_conv.is_owned = false;
27639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27640         LDKThirtyTwoBytes val_ref;
27641         CHECK((*env)->GetArrayLength(env, val) == 32);
27642         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27643         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27644 }
27645
27646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27647         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27649         this_ptr_conv.is_owned = false;
27650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27651         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27652         return ret_conv;
27653 }
27654
27655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27656         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27658         this_ptr_conv.is_owned = false;
27659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27660         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27661 }
27662
27663 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) {
27664         LDKOutPoint outpoint_arg_conv;
27665         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
27666         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27668         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27669         LDKPublicKey per_commitment_point_arg_ref;
27670         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
27671         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
27672         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
27673         CHECK_ACCESS(output_arg_ptr);
27674         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27675         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
27676         LDKPublicKey revocation_pubkey_arg_ref;
27677         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
27678         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
27679         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27680         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27681         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27682         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);
27683         int64_t ret_ref = 0;
27684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27687         ret_ref = (uintptr_t)ret_var.inner;
27688         if (ret_var.is_owned) {
27689                 ret_ref |= 1;
27690         }
27691         return ret_ref;
27692 }
27693
27694 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
27695         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
27696 int64_t ret_ref = 0;
27697 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27698 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27699 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27700 ret_ref = (uintptr_t)ret_var.inner;
27701 if (ret_var.is_owned) {
27702         ret_ref |= 1;
27703 }
27704         return ret_ref;
27705 }
27706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27707         LDKDelayedPaymentOutputDescriptor arg_conv;
27708         arg_conv.inner = (void*)(arg & (~1));
27709         arg_conv.is_owned = false;
27710         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27711         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
27712         return ret_conv;
27713 }
27714
27715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27716         LDKDelayedPaymentOutputDescriptor orig_conv;
27717         orig_conv.inner = (void*)(orig & (~1));
27718         orig_conv.is_owned = false;
27719         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27720         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
27721         int64_t ret_ref = 0;
27722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27725         ret_ref = (uintptr_t)ret_var.inner;
27726         if (ret_var.is_owned) {
27727                 ret_ref |= 1;
27728         }
27729         return ret_ref;
27730 }
27731
27732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27733         LDKDelayedPaymentOutputDescriptor obj_conv;
27734         obj_conv.inner = (void*)(obj & (~1));
27735         obj_conv.is_owned = false;
27736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27737         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
27738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27740         CVec_u8Z_free(ret_var);
27741         return ret_arr;
27742 }
27743
27744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27745         LDKu8slice ser_ref;
27746         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27747         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27748         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
27749         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
27750         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27751         return (int64_t)ret_conv;
27752 }
27753
27754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27755         LDKStaticPaymentOutputDescriptor this_obj_conv;
27756         this_obj_conv.inner = (void*)(this_obj & (~1));
27757         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27759         StaticPaymentOutputDescriptor_free(this_obj_conv);
27760 }
27761
27762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27763         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27765         this_ptr_conv.is_owned = false;
27766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27767         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
27768         int64_t ret_ref = 0;
27769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27772         ret_ref = (uintptr_t)ret_var.inner;
27773         if (ret_var.is_owned) {
27774                 ret_ref |= 1;
27775         }
27776         return ret_ref;
27777 }
27778
27779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27780         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27782         this_ptr_conv.is_owned = false;
27783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27784         LDKOutPoint val_conv;
27785         val_conv.inner = (void*)(val & (~1));
27786         val_conv.is_owned = (val & 1) || (val == 0);
27787         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27788         val_conv = OutPoint_clone(&val_conv);
27789         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27790 }
27791
27792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27793         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27795         this_ptr_conv.is_owned = false;
27796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27797         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27798         CHECK_ACCESS(val_ptr);
27799         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27800         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
27801         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27802 }
27803
27804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27805         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27807         this_ptr_conv.is_owned = false;
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27811         return ret_arr;
27812 }
27813
27814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27815         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27817         this_ptr_conv.is_owned = false;
27818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27819         LDKThirtyTwoBytes val_ref;
27820         CHECK((*env)->GetArrayLength(env, val) == 32);
27821         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27822         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27823 }
27824
27825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27826         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27828         this_ptr_conv.is_owned = false;
27829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27830         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27831         return ret_conv;
27832 }
27833
27834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27835         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27837         this_ptr_conv.is_owned = false;
27838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27839         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27840 }
27841
27842 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) {
27843         LDKOutPoint outpoint_arg_conv;
27844         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
27845         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27847         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27848         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
27849         CHECK_ACCESS(output_arg_ptr);
27850         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27851         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
27852         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27853         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27854         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27855         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
27856         int64_t ret_ref = 0;
27857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27860         ret_ref = (uintptr_t)ret_var.inner;
27861         if (ret_var.is_owned) {
27862                 ret_ref |= 1;
27863         }
27864         return ret_ref;
27865 }
27866
27867 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
27868         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
27869 int64_t ret_ref = 0;
27870 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27871 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27872 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27873 ret_ref = (uintptr_t)ret_var.inner;
27874 if (ret_var.is_owned) {
27875         ret_ref |= 1;
27876 }
27877         return ret_ref;
27878 }
27879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27880         LDKStaticPaymentOutputDescriptor arg_conv;
27881         arg_conv.inner = (void*)(arg & (~1));
27882         arg_conv.is_owned = false;
27883         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27884         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
27885         return ret_conv;
27886 }
27887
27888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27889         LDKStaticPaymentOutputDescriptor orig_conv;
27890         orig_conv.inner = (void*)(orig & (~1));
27891         orig_conv.is_owned = false;
27892         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27893         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
27894         int64_t ret_ref = 0;
27895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27898         ret_ref = (uintptr_t)ret_var.inner;
27899         if (ret_var.is_owned) {
27900                 ret_ref |= 1;
27901         }
27902         return ret_ref;
27903 }
27904
27905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27906         LDKStaticPaymentOutputDescriptor obj_conv;
27907         obj_conv.inner = (void*)(obj & (~1));
27908         obj_conv.is_owned = false;
27909         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27910         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
27911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27913         CVec_u8Z_free(ret_var);
27914         return ret_arr;
27915 }
27916
27917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27918         LDKu8slice ser_ref;
27919         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27920         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27921         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
27922         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
27923         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27924         return (int64_t)ret_conv;
27925 }
27926
27927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27928         if ((this_ptr & 1) != 0) return;
27929         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27930         CHECK_ACCESS(this_ptr_ptr);
27931         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
27932         FREE((void*)this_ptr);
27933         SpendableOutputDescriptor_free(this_ptr_conv);
27934 }
27935
27936 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27937         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27938         *ret_copy = SpendableOutputDescriptor_clone(arg);
27939 int64_t ret_ref = (uintptr_t)ret_copy;
27940         return ret_ref;
27941 }
27942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27943         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
27944         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
27945         return ret_conv;
27946 }
27947
27948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27949         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
27950         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27951         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27952         int64_t ret_ref = (uintptr_t)ret_copy;
27953         return ret_ref;
27954 }
27955
27956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27957         LDKOutPoint outpoint_conv;
27958         outpoint_conv.inner = (void*)(outpoint & (~1));
27959         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
27960         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27961         outpoint_conv = OutPoint_clone(&outpoint_conv);
27962         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
27963         CHECK_ACCESS(output_ptr);
27964         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27965         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
27966         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27967         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27968         int64_t ret_ref = (uintptr_t)ret_copy;
27969         return ret_ref;
27970 }
27971
27972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27973         LDKDelayedPaymentOutputDescriptor a_conv;
27974         a_conv.inner = (void*)(a & (~1));
27975         a_conv.is_owned = (a & 1) || (a == 0);
27976         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27977         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27978         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27979         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27980         int64_t ret_ref = (uintptr_t)ret_copy;
27981         return ret_ref;
27982 }
27983
27984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27985         LDKStaticPaymentOutputDescriptor a_conv;
27986         a_conv.inner = (void*)(a & (~1));
27987         a_conv.is_owned = (a & 1) || (a == 0);
27988         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27989         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27990         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27991         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27992         int64_t ret_ref = (uintptr_t)ret_copy;
27993         return ret_ref;
27994 }
27995
27996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27997         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
27998         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28001         CVec_u8Z_free(ret_var);
28002         return ret_arr;
28003 }
28004
28005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28006         LDKu8slice ser_ref;
28007         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28008         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28009         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
28010         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
28011         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28012         return (int64_t)ret_conv;
28013 }
28014
28015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28016         if ((this_ptr & 1) != 0) return;
28017         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28018         CHECK_ACCESS(this_ptr_ptr);
28019         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
28020         FREE((void*)this_ptr);
28021         BaseSign_free(this_ptr_conv);
28022 }
28023
28024 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
28025         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28026         *ret_ret = Sign_clone(arg);
28027         return (int64_t)ret_ret;
28028 }
28029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28030         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28031         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28032         LDKSign* arg_conv = (LDKSign*)arg_ptr;
28033         int64_t ret_conv = Sign_clone_ptr(arg_conv);
28034         return ret_conv;
28035 }
28036
28037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28038         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28039         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28040         LDKSign* orig_conv = (LDKSign*)orig_ptr;
28041         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28042         *ret_ret = Sign_clone(orig_conv);
28043         return (int64_t)ret_ret;
28044 }
28045
28046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28047         if ((this_ptr & 1) != 0) return;
28048         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28049         CHECK_ACCESS(this_ptr_ptr);
28050         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
28051         FREE((void*)this_ptr);
28052         Sign_free(this_ptr_conv);
28053 }
28054
28055 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28056         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
28057         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
28058         return ret_conv;
28059 }
28060
28061 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
28062         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
28063         return ret_conv;
28064 }
28065
28066 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
28067         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
28068         return ret_conv;
28069 }
28070
28071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28072         if ((this_ptr & 1) != 0) return;
28073         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28074         CHECK_ACCESS(this_ptr_ptr);
28075         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
28076         FREE((void*)this_ptr);
28077         KeysInterface_free(this_ptr_conv);
28078 }
28079
28080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28081         LDKInMemorySigner this_obj_conv;
28082         this_obj_conv.inner = (void*)(this_obj & (~1));
28083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28085         InMemorySigner_free(this_obj_conv);
28086 }
28087
28088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28089         LDKInMemorySigner this_ptr_conv;
28090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28091         this_ptr_conv.is_owned = false;
28092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28093         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28094         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
28095         return ret_arr;
28096 }
28097
28098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28099         LDKInMemorySigner this_ptr_conv;
28100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28101         this_ptr_conv.is_owned = false;
28102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28103         LDKSecretKey val_ref;
28104         CHECK((*env)->GetArrayLength(env, val) == 32);
28105         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28106         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
28107 }
28108
28109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28110         LDKInMemorySigner this_ptr_conv;
28111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28112         this_ptr_conv.is_owned = false;
28113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28114         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
28116         return ret_arr;
28117 }
28118
28119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28120         LDKInMemorySigner this_ptr_conv;
28121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28122         this_ptr_conv.is_owned = false;
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28124         LDKSecretKey val_ref;
28125         CHECK((*env)->GetArrayLength(env, val) == 32);
28126         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28127         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
28128 }
28129
28130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28131         LDKInMemorySigner this_ptr_conv;
28132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28133         this_ptr_conv.is_owned = false;
28134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28135         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
28137         return ret_arr;
28138 }
28139
28140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28141         LDKInMemorySigner this_ptr_conv;
28142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28143         this_ptr_conv.is_owned = false;
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28145         LDKSecretKey val_ref;
28146         CHECK((*env)->GetArrayLength(env, val) == 32);
28147         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28148         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
28149 }
28150
28151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28152         LDKInMemorySigner this_ptr_conv;
28153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28154         this_ptr_conv.is_owned = false;
28155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28156         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28157         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
28158         return ret_arr;
28159 }
28160
28161 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) {
28162         LDKInMemorySigner this_ptr_conv;
28163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28164         this_ptr_conv.is_owned = false;
28165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28166         LDKSecretKey val_ref;
28167         CHECK((*env)->GetArrayLength(env, val) == 32);
28168         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28169         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
28170 }
28171
28172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28173         LDKInMemorySigner this_ptr_conv;
28174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28175         this_ptr_conv.is_owned = false;
28176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28177         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
28179         return ret_arr;
28180 }
28181
28182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28183         LDKInMemorySigner this_ptr_conv;
28184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28185         this_ptr_conv.is_owned = false;
28186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28187         LDKSecretKey val_ref;
28188         CHECK((*env)->GetArrayLength(env, val) == 32);
28189         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28190         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
28191 }
28192
28193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
28194         LDKInMemorySigner this_ptr_conv;
28195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28196         this_ptr_conv.is_owned = false;
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28198         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
28200         return ret_arr;
28201 }
28202
28203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28204         LDKInMemorySigner this_ptr_conv;
28205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28206         this_ptr_conv.is_owned = false;
28207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28208         LDKThirtyTwoBytes val_ref;
28209         CHECK((*env)->GetArrayLength(env, val) == 32);
28210         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28211         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
28212 }
28213
28214 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
28215         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
28216 int64_t ret_ref = 0;
28217 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28218 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28219 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28220 ret_ref = (uintptr_t)ret_var.inner;
28221 if (ret_var.is_owned) {
28222         ret_ref |= 1;
28223 }
28224         return ret_ref;
28225 }
28226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28227         LDKInMemorySigner arg_conv;
28228         arg_conv.inner = (void*)(arg & (~1));
28229         arg_conv.is_owned = false;
28230         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28231         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
28232         return ret_conv;
28233 }
28234
28235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28236         LDKInMemorySigner orig_conv;
28237         orig_conv.inner = (void*)(orig & (~1));
28238         orig_conv.is_owned = false;
28239         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28240         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
28241         int64_t ret_ref = 0;
28242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28245         ret_ref = (uintptr_t)ret_var.inner;
28246         if (ret_var.is_owned) {
28247                 ret_ref |= 1;
28248         }
28249         return ret_ref;
28250 }
28251
28252 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) {
28253         LDKSecretKey node_secret_ref;
28254         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
28255         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
28256         LDKSecretKey funding_key_ref;
28257         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28258         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
28259         LDKSecretKey revocation_base_key_ref;
28260         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
28261         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
28262         LDKSecretKey payment_key_ref;
28263         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
28264         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
28265         LDKSecretKey delayed_payment_base_key_ref;
28266         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
28267         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
28268         LDKSecretKey htlc_base_key_ref;
28269         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28270         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
28271         LDKThirtyTwoBytes commitment_seed_ref;
28272         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
28273         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28274         LDKThirtyTwoBytes channel_keys_id_ref;
28275         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28276         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28277         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);
28278         int64_t ret_ref = 0;
28279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28282         ret_ref = (uintptr_t)ret_var.inner;
28283         if (ret_var.is_owned) {
28284                 ret_ref |= 1;
28285         }
28286         return ret_ref;
28287 }
28288
28289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28290         LDKInMemorySigner this_arg_conv;
28291         this_arg_conv.inner = (void*)(this_arg & (~1));
28292         this_arg_conv.is_owned = false;
28293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28294         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28295         int64_t ret_ref = 0;
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         return ret_ref;
28304 }
28305
28306 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28307         LDKInMemorySigner this_arg_conv;
28308         this_arg_conv.inner = (void*)(this_arg & (~1));
28309         this_arg_conv.is_owned = false;
28310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28311         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28312         return ret_conv;
28313 }
28314
28315 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28316         LDKInMemorySigner this_arg_conv;
28317         this_arg_conv.inner = (void*)(this_arg & (~1));
28318         this_arg_conv.is_owned = false;
28319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28320         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
28321         return ret_conv;
28322 }
28323
28324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
28325         LDKInMemorySigner this_arg_conv;
28326         this_arg_conv.inner = (void*)(this_arg & (~1));
28327         this_arg_conv.is_owned = false;
28328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28329         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
28330         return ret_conv;
28331 }
28332
28333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
28334         LDKInMemorySigner this_arg_conv;
28335         this_arg_conv.inner = (void*)(this_arg & (~1));
28336         this_arg_conv.is_owned = false;
28337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28338         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
28339         int64_t ret_ref = 0;
28340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28343         ret_ref = (uintptr_t)ret_var.inner;
28344         if (ret_var.is_owned) {
28345                 ret_ref |= 1;
28346         }
28347         return ret_ref;
28348 }
28349
28350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
28351         LDKInMemorySigner this_arg_conv;
28352         this_arg_conv.inner = (void*)(this_arg & (~1));
28353         this_arg_conv.is_owned = false;
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28355         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
28356         int64_t ret_ref = 0;
28357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28360         ret_ref = (uintptr_t)ret_var.inner;
28361         if (ret_var.is_owned) {
28362                 ret_ref |= 1;
28363         }
28364         return ret_ref;
28365 }
28366
28367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
28368         LDKInMemorySigner this_arg_conv;
28369         this_arg_conv.inner = (void*)(this_arg & (~1));
28370         this_arg_conv.is_owned = false;
28371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28372         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
28373         return ret_conv;
28374 }
28375
28376 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) {
28377         LDKInMemorySigner this_arg_conv;
28378         this_arg_conv.inner = (void*)(this_arg & (~1));
28379         this_arg_conv.is_owned = false;
28380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28381         LDKTransaction spend_tx_ref;
28382         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
28383         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
28384         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
28385         spend_tx_ref.data_is_owned = true;
28386         LDKStaticPaymentOutputDescriptor descriptor_conv;
28387         descriptor_conv.inner = (void*)(descriptor & (~1));
28388         descriptor_conv.is_owned = false;
28389         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
28390         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
28391         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
28392         return (int64_t)ret_conv;
28393 }
28394
28395 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) {
28396         LDKInMemorySigner this_arg_conv;
28397         this_arg_conv.inner = (void*)(this_arg & (~1));
28398         this_arg_conv.is_owned = false;
28399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28400         LDKTransaction spend_tx_ref;
28401         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
28402         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
28403         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
28404         spend_tx_ref.data_is_owned = true;
28405         LDKDelayedPaymentOutputDescriptor descriptor_conv;
28406         descriptor_conv.inner = (void*)(descriptor & (~1));
28407         descriptor_conv.is_owned = false;
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
28409         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
28410         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
28411         return (int64_t)ret_conv;
28412 }
28413
28414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
28415         LDKInMemorySigner this_arg_conv;
28416         this_arg_conv.inner = (void*)(this_arg & (~1));
28417         this_arg_conv.is_owned = false;
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28419         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
28420         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
28421         return (int64_t)ret_ret;
28422 }
28423
28424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
28425         LDKInMemorySigner this_arg_conv;
28426         this_arg_conv.inner = (void*)(this_arg & (~1));
28427         this_arg_conv.is_owned = false;
28428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28429         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28430         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
28431         return (int64_t)ret_ret;
28432 }
28433
28434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
28435         LDKInMemorySigner obj_conv;
28436         obj_conv.inner = (void*)(obj & (~1));
28437         obj_conv.is_owned = false;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28439         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
28440         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28441         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28442         CVec_u8Z_free(ret_var);
28443         return ret_arr;
28444 }
28445
28446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
28447         LDKu8slice ser_ref;
28448         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28449         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28450         LDKSecretKey arg_ref;
28451         CHECK((*env)->GetArrayLength(env, arg) == 32);
28452         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
28453         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
28454         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
28455         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28456         return (int64_t)ret_conv;
28457 }
28458
28459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28460         LDKKeysManager this_obj_conv;
28461         this_obj_conv.inner = (void*)(this_obj & (~1));
28462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28464         KeysManager_free(this_obj_conv);
28465 }
28466
28467 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) {
28468         unsigned char seed_arr[32];
28469         CHECK((*env)->GetArrayLength(env, seed) == 32);
28470         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
28471         unsigned char (*seed_ref)[32] = &seed_arr;
28472         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
28473         int64_t ret_ref = 0;
28474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28477         ret_ref = (uintptr_t)ret_var.inner;
28478         if (ret_var.is_owned) {
28479                 ret_ref |= 1;
28480         }
28481         return ret_ref;
28482 }
28483
28484 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) {
28485         LDKKeysManager this_arg_conv;
28486         this_arg_conv.inner = (void*)(this_arg & (~1));
28487         this_arg_conv.is_owned = false;
28488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28489         unsigned char params_arr[32];
28490         CHECK((*env)->GetArrayLength(env, params) == 32);
28491         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
28492         unsigned char (*params_ref)[32] = &params_arr;
28493         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
28494         int64_t ret_ref = 0;
28495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28498         ret_ref = (uintptr_t)ret_var.inner;
28499         if (ret_var.is_owned) {
28500                 ret_ref |= 1;
28501         }
28502         return ret_ref;
28503 }
28504
28505 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) {
28506         LDKKeysManager this_arg_conv;
28507         this_arg_conv.inner = (void*)(this_arg & (~1));
28508         this_arg_conv.is_owned = false;
28509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28510         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
28511         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
28512         if (descriptors_constr.datalen > 0)
28513                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
28514         else
28515                 descriptors_constr.data = NULL;
28516         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
28517         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
28518                 int64_t descriptors_conv_27 = descriptors_vals[b];
28519                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
28520                 CHECK_ACCESS(descriptors_conv_27_ptr);
28521                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
28522                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
28523                 descriptors_constr.data[b] = descriptors_conv_27_conv;
28524         }
28525         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
28526         LDKCVec_TxOutZ outputs_constr;
28527         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
28528         if (outputs_constr.datalen > 0)
28529                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
28530         else
28531                 outputs_constr.data = NULL;
28532         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
28533         for (size_t h = 0; h < outputs_constr.datalen; h++) {
28534                 int64_t outputs_conv_7 = outputs_vals[h];
28535                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
28536                 CHECK_ACCESS(outputs_conv_7_ptr);
28537                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
28538                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
28539                 outputs_constr.data[h] = outputs_conv_7_conv;
28540         }
28541         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
28542         LDKCVec_u8Z change_destination_script_ref;
28543         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
28544         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
28545         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
28546         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
28547         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
28548         return (int64_t)ret_conv;
28549 }
28550
28551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
28552         LDKKeysManager this_arg_conv;
28553         this_arg_conv.inner = (void*)(this_arg & (~1));
28554         this_arg_conv.is_owned = false;
28555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28556         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
28557         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
28558         return (int64_t)ret_ret;
28559 }
28560
28561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28562         LDKPhantomKeysManager this_obj_conv;
28563         this_obj_conv.inner = (void*)(this_obj & (~1));
28564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28566         PhantomKeysManager_free(this_obj_conv);
28567 }
28568
28569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
28570         LDKPhantomKeysManager this_arg_conv;
28571         this_arg_conv.inner = (void*)(this_arg & (~1));
28572         this_arg_conv.is_owned = false;
28573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28574         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
28575         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
28576         return (int64_t)ret_ret;
28577 }
28578
28579 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) {
28580         unsigned char seed_arr[32];
28581         CHECK((*env)->GetArrayLength(env, seed) == 32);
28582         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
28583         unsigned char (*seed_ref)[32] = &seed_arr;
28584         unsigned char cross_node_seed_arr[32];
28585         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
28586         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
28587         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
28588         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
28589         int64_t ret_ref = 0;
28590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28593         ret_ref = (uintptr_t)ret_var.inner;
28594         if (ret_var.is_owned) {
28595                 ret_ref |= 1;
28596         }
28597         return ret_ref;
28598 }
28599
28600 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) {
28601         LDKPhantomKeysManager this_arg_conv;
28602         this_arg_conv.inner = (void*)(this_arg & (~1));
28603         this_arg_conv.is_owned = false;
28604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28605         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
28606         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
28607         if (descriptors_constr.datalen > 0)
28608                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
28609         else
28610                 descriptors_constr.data = NULL;
28611         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
28612         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
28613                 int64_t descriptors_conv_27 = descriptors_vals[b];
28614                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
28615                 CHECK_ACCESS(descriptors_conv_27_ptr);
28616                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
28617                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
28618                 descriptors_constr.data[b] = descriptors_conv_27_conv;
28619         }
28620         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
28621         LDKCVec_TxOutZ outputs_constr;
28622         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
28623         if (outputs_constr.datalen > 0)
28624                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
28625         else
28626                 outputs_constr.data = NULL;
28627         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
28628         for (size_t h = 0; h < outputs_constr.datalen; h++) {
28629                 int64_t outputs_conv_7 = outputs_vals[h];
28630                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
28631                 CHECK_ACCESS(outputs_conv_7_ptr);
28632                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
28633                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
28634                 outputs_constr.data[h] = outputs_conv_7_conv;
28635         }
28636         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
28637         LDKCVec_u8Z change_destination_script_ref;
28638         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
28639         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
28640         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
28641         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
28642         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
28643         return (int64_t)ret_conv;
28644 }
28645
28646 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) {
28647         LDKPhantomKeysManager this_arg_conv;
28648         this_arg_conv.inner = (void*)(this_arg & (~1));
28649         this_arg_conv.is_owned = false;
28650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28651         unsigned char params_arr[32];
28652         CHECK((*env)->GetArrayLength(env, params) == 32);
28653         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
28654         unsigned char (*params_ref)[32] = &params_arr;
28655         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
28656         int64_t ret_ref = 0;
28657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28660         ret_ref = (uintptr_t)ret_var.inner;
28661         if (ret_var.is_owned) {
28662                 ret_ref |= 1;
28663         }
28664         return ret_ref;
28665 }
28666
28667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28668         LDKChannelManager this_obj_conv;
28669         this_obj_conv.inner = (void*)(this_obj & (~1));
28670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28672         ChannelManager_free(this_obj_conv);
28673 }
28674
28675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28676         LDKChainParameters this_obj_conv;
28677         this_obj_conv.inner = (void*)(this_obj & (~1));
28678         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28680         ChainParameters_free(this_obj_conv);
28681 }
28682
28683 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
28684         LDKChainParameters this_ptr_conv;
28685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28686         this_ptr_conv.is_owned = false;
28687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28688         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
28689         return ret_conv;
28690 }
28691
28692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
28693         LDKChainParameters this_ptr_conv;
28694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28695         this_ptr_conv.is_owned = false;
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28697         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
28698         ChainParameters_set_network(&this_ptr_conv, val_conv);
28699 }
28700
28701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
28702         LDKChainParameters this_ptr_conv;
28703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28704         this_ptr_conv.is_owned = false;
28705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28706         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
28707         int64_t ret_ref = 0;
28708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28711         ret_ref = (uintptr_t)ret_var.inner;
28712         if (ret_var.is_owned) {
28713                 ret_ref |= 1;
28714         }
28715         return ret_ref;
28716 }
28717
28718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28719         LDKChainParameters this_ptr_conv;
28720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28721         this_ptr_conv.is_owned = false;
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28723         LDKBestBlock val_conv;
28724         val_conv.inner = (void*)(val & (~1));
28725         val_conv.is_owned = (val & 1) || (val == 0);
28726         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28727         val_conv = BestBlock_clone(&val_conv);
28728         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
28729 }
28730
28731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
28732         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
28733         LDKBestBlock best_block_arg_conv;
28734         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
28735         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
28736         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
28737         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
28738         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
28739         int64_t ret_ref = 0;
28740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28743         ret_ref = (uintptr_t)ret_var.inner;
28744         if (ret_var.is_owned) {
28745                 ret_ref |= 1;
28746         }
28747         return ret_ref;
28748 }
28749
28750 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
28751         LDKChainParameters ret_var = ChainParameters_clone(arg);
28752 int64_t ret_ref = 0;
28753 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28754 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28755 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28756 ret_ref = (uintptr_t)ret_var.inner;
28757 if (ret_var.is_owned) {
28758         ret_ref |= 1;
28759 }
28760         return ret_ref;
28761 }
28762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28763         LDKChainParameters arg_conv;
28764         arg_conv.inner = (void*)(arg & (~1));
28765         arg_conv.is_owned = false;
28766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28767         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
28768         return ret_conv;
28769 }
28770
28771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28772         LDKChainParameters orig_conv;
28773         orig_conv.inner = (void*)(orig & (~1));
28774         orig_conv.is_owned = false;
28775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28776         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
28777         int64_t ret_ref = 0;
28778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28781         ret_ref = (uintptr_t)ret_var.inner;
28782         if (ret_var.is_owned) {
28783                 ret_ref |= 1;
28784         }
28785         return ret_ref;
28786 }
28787
28788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28789         LDKCounterpartyForwardingInfo this_obj_conv;
28790         this_obj_conv.inner = (void*)(this_obj & (~1));
28791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28793         CounterpartyForwardingInfo_free(this_obj_conv);
28794 }
28795
28796 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28797         LDKCounterpartyForwardingInfo this_ptr_conv;
28798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28799         this_ptr_conv.is_owned = false;
28800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28801         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
28802         return ret_conv;
28803 }
28804
28805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28806         LDKCounterpartyForwardingInfo this_ptr_conv;
28807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28808         this_ptr_conv.is_owned = false;
28809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28810         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
28811 }
28812
28813 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28814         LDKCounterpartyForwardingInfo this_ptr_conv;
28815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28816         this_ptr_conv.is_owned = false;
28817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28818         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
28819         return ret_conv;
28820 }
28821
28822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28823         LDKCounterpartyForwardingInfo this_ptr_conv;
28824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28825         this_ptr_conv.is_owned = false;
28826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28827         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
28828 }
28829
28830 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28831         LDKCounterpartyForwardingInfo this_ptr_conv;
28832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28833         this_ptr_conv.is_owned = false;
28834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28835         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
28836         return ret_conv;
28837 }
28838
28839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28840         LDKCounterpartyForwardingInfo this_ptr_conv;
28841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28842         this_ptr_conv.is_owned = false;
28843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28844         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
28845 }
28846
28847 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) {
28848         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
28849         int64_t ret_ref = 0;
28850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28853         ret_ref = (uintptr_t)ret_var.inner;
28854         if (ret_var.is_owned) {
28855                 ret_ref |= 1;
28856         }
28857         return ret_ref;
28858 }
28859
28860 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
28861         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
28862 int64_t ret_ref = 0;
28863 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28864 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28865 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28866 ret_ref = (uintptr_t)ret_var.inner;
28867 if (ret_var.is_owned) {
28868         ret_ref |= 1;
28869 }
28870         return ret_ref;
28871 }
28872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28873         LDKCounterpartyForwardingInfo arg_conv;
28874         arg_conv.inner = (void*)(arg & (~1));
28875         arg_conv.is_owned = false;
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28877         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
28878         return ret_conv;
28879 }
28880
28881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28882         LDKCounterpartyForwardingInfo orig_conv;
28883         orig_conv.inner = (void*)(orig & (~1));
28884         orig_conv.is_owned = false;
28885         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28886         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
28887         int64_t ret_ref = 0;
28888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28891         ret_ref = (uintptr_t)ret_var.inner;
28892         if (ret_var.is_owned) {
28893                 ret_ref |= 1;
28894         }
28895         return ret_ref;
28896 }
28897
28898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28899         LDKChannelCounterparty this_obj_conv;
28900         this_obj_conv.inner = (void*)(this_obj & (~1));
28901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28903         ChannelCounterparty_free(this_obj_conv);
28904 }
28905
28906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28907         LDKChannelCounterparty this_ptr_conv;
28908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28909         this_ptr_conv.is_owned = false;
28910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28911         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
28913         return ret_arr;
28914 }
28915
28916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28917         LDKChannelCounterparty this_ptr_conv;
28918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28919         this_ptr_conv.is_owned = false;
28920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28921         LDKPublicKey val_ref;
28922         CHECK((*env)->GetArrayLength(env, val) == 33);
28923         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28924         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
28925 }
28926
28927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28928         LDKChannelCounterparty this_ptr_conv;
28929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28930         this_ptr_conv.is_owned = false;
28931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28932         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
28933         int64_t ret_ref = 0;
28934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28937         ret_ref = (uintptr_t)ret_var.inner;
28938         if (ret_var.is_owned) {
28939                 ret_ref |= 1;
28940         }
28941         return ret_ref;
28942 }
28943
28944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28945         LDKChannelCounterparty this_ptr_conv;
28946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28947         this_ptr_conv.is_owned = false;
28948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28949         LDKInitFeatures val_conv;
28950         val_conv.inner = (void*)(val & (~1));
28951         val_conv.is_owned = (val & 1) || (val == 0);
28952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28953         val_conv = InitFeatures_clone(&val_conv);
28954         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28955 }
28956
28957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28958         LDKChannelCounterparty this_ptr_conv;
28959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28960         this_ptr_conv.is_owned = false;
28961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28962         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28963         return ret_conv;
28964 }
28965
28966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28967         LDKChannelCounterparty this_ptr_conv;
28968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28969         this_ptr_conv.is_owned = false;
28970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28971         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28972 }
28973
28974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28975         LDKChannelCounterparty this_ptr_conv;
28976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28977         this_ptr_conv.is_owned = false;
28978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28979         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28980         int64_t ret_ref = 0;
28981         if ((uintptr_t)ret_var.inner > 4096) {
28982                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28983                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28985                 ret_ref = (uintptr_t)ret_var.inner;
28986                 if (ret_var.is_owned) {
28987                         ret_ref |= 1;
28988                 }
28989         }
28990         return ret_ref;
28991 }
28992
28993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28994         LDKChannelCounterparty this_ptr_conv;
28995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28996         this_ptr_conv.is_owned = false;
28997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28998         LDKCounterpartyForwardingInfo val_conv;
28999         val_conv.inner = (void*)(val & (~1));
29000         val_conv.is_owned = (val & 1) || (val == 0);
29001         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29002         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
29003         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
29004 }
29005
29006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29007         LDKChannelCounterparty this_ptr_conv;
29008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29009         this_ptr_conv.is_owned = false;
29010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29011         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29012         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
29013         int64_t ret_ref = (uintptr_t)ret_copy;
29014         return ret_ref;
29015 }
29016
29017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29018         LDKChannelCounterparty this_ptr_conv;
29019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29020         this_ptr_conv.is_owned = false;
29021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29022         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29023         CHECK_ACCESS(val_ptr);
29024         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29025         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29026         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29027 }
29028
29029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29030         LDKChannelCounterparty this_ptr_conv;
29031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29032         this_ptr_conv.is_owned = false;
29033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29034         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29035         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
29036         int64_t ret_ref = (uintptr_t)ret_copy;
29037         return ret_ref;
29038 }
29039
29040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29041         LDKChannelCounterparty this_ptr_conv;
29042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29043         this_ptr_conv.is_owned = false;
29044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29045         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29046         CHECK_ACCESS(val_ptr);
29047         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29048         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29049         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29050 }
29051
29052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
29053         LDKPublicKey node_id_arg_ref;
29054         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
29055         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
29056         LDKInitFeatures features_arg_conv;
29057         features_arg_conv.inner = (void*)(features_arg & (~1));
29058         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29059         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29060         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29061         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
29062         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
29063         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
29064         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
29065         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
29066         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
29067         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
29068         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
29069         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
29070         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
29071         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
29072         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
29073         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
29074         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
29075         int64_t ret_ref = 0;
29076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29079         ret_ref = (uintptr_t)ret_var.inner;
29080         if (ret_var.is_owned) {
29081                 ret_ref |= 1;
29082         }
29083         return ret_ref;
29084 }
29085
29086 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
29087         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
29088 int64_t ret_ref = 0;
29089 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29090 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29091 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29092 ret_ref = (uintptr_t)ret_var.inner;
29093 if (ret_var.is_owned) {
29094         ret_ref |= 1;
29095 }
29096         return ret_ref;
29097 }
29098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29099         LDKChannelCounterparty arg_conv;
29100         arg_conv.inner = (void*)(arg & (~1));
29101         arg_conv.is_owned = false;
29102         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29103         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
29104         return ret_conv;
29105 }
29106
29107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29108         LDKChannelCounterparty orig_conv;
29109         orig_conv.inner = (void*)(orig & (~1));
29110         orig_conv.is_owned = false;
29111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29112         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
29113         int64_t ret_ref = 0;
29114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29117         ret_ref = (uintptr_t)ret_var.inner;
29118         if (ret_var.is_owned) {
29119                 ret_ref |= 1;
29120         }
29121         return ret_ref;
29122 }
29123
29124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29125         LDKChannelDetails this_obj_conv;
29126         this_obj_conv.inner = (void*)(this_obj & (~1));
29127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29129         ChannelDetails_free(this_obj_conv);
29130 }
29131
29132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29133         LDKChannelDetails this_ptr_conv;
29134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29135         this_ptr_conv.is_owned = false;
29136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29137         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
29139         return ret_arr;
29140 }
29141
29142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29143         LDKChannelDetails this_ptr_conv;
29144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29145         this_ptr_conv.is_owned = false;
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29147         LDKThirtyTwoBytes val_ref;
29148         CHECK((*env)->GetArrayLength(env, val) == 32);
29149         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29150         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
29151 }
29152
29153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
29154         LDKChannelDetails this_ptr_conv;
29155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29156         this_ptr_conv.is_owned = false;
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29158         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
29159         int64_t ret_ref = 0;
29160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29163         ret_ref = (uintptr_t)ret_var.inner;
29164         if (ret_var.is_owned) {
29165                 ret_ref |= 1;
29166         }
29167         return ret_ref;
29168 }
29169
29170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29171         LDKChannelDetails this_ptr_conv;
29172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29173         this_ptr_conv.is_owned = false;
29174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29175         LDKChannelCounterparty val_conv;
29176         val_conv.inner = (void*)(val & (~1));
29177         val_conv.is_owned = (val & 1) || (val == 0);
29178         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29179         val_conv = ChannelCounterparty_clone(&val_conv);
29180         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
29181 }
29182
29183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
29184         LDKChannelDetails this_ptr_conv;
29185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29186         this_ptr_conv.is_owned = false;
29187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29188         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
29189         int64_t ret_ref = 0;
29190         if ((uintptr_t)ret_var.inner > 4096) {
29191                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29192                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29194                 ret_ref = (uintptr_t)ret_var.inner;
29195                 if (ret_var.is_owned) {
29196                         ret_ref |= 1;
29197                 }
29198         }
29199         return ret_ref;
29200 }
29201
29202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29203         LDKChannelDetails this_ptr_conv;
29204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29205         this_ptr_conv.is_owned = false;
29206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29207         LDKOutPoint val_conv;
29208         val_conv.inner = (void*)(val & (~1));
29209         val_conv.is_owned = (val & 1) || (val == 0);
29210         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29211         val_conv = OutPoint_clone(&val_conv);
29212         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
29213 }
29214
29215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
29216         LDKChannelDetails this_ptr_conv;
29217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29218         this_ptr_conv.is_owned = false;
29219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29220         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
29221         int64_t ret_ref = 0;
29222         if ((uintptr_t)ret_var.inner > 4096) {
29223                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29224                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29226                 ret_ref = (uintptr_t)ret_var.inner;
29227                 if (ret_var.is_owned) {
29228                         ret_ref |= 1;
29229                 }
29230         }
29231         return ret_ref;
29232 }
29233
29234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29235         LDKChannelDetails this_ptr_conv;
29236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29237         this_ptr_conv.is_owned = false;
29238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29239         LDKChannelTypeFeatures val_conv;
29240         val_conv.inner = (void*)(val & (~1));
29241         val_conv.is_owned = (val & 1) || (val == 0);
29242         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29243         val_conv = ChannelTypeFeatures_clone(&val_conv);
29244         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
29245 }
29246
29247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29248         LDKChannelDetails this_ptr_conv;
29249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29250         this_ptr_conv.is_owned = false;
29251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29252         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29253         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
29254         int64_t ret_ref = (uintptr_t)ret_copy;
29255         return ret_ref;
29256 }
29257
29258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29259         LDKChannelDetails this_ptr_conv;
29260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29261         this_ptr_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29263         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29264         CHECK_ACCESS(val_ptr);
29265         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29266         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29267         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
29268 }
29269
29270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29271         LDKChannelDetails this_ptr_conv;
29272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29273         this_ptr_conv.is_owned = false;
29274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29275         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29276         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29277         int64_t ret_ref = (uintptr_t)ret_copy;
29278         return ret_ref;
29279 }
29280
29281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29282         LDKChannelDetails this_ptr_conv;
29283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29284         this_ptr_conv.is_owned = false;
29285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29286         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29287         CHECK_ACCESS(val_ptr);
29288         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29289         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29290         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29291 }
29292
29293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29294         LDKChannelDetails this_ptr_conv;
29295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29296         this_ptr_conv.is_owned = false;
29297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29298         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29299         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29300         int64_t ret_ref = (uintptr_t)ret_copy;
29301         return ret_ref;
29302 }
29303
29304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29305         LDKChannelDetails this_ptr_conv;
29306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29307         this_ptr_conv.is_owned = false;
29308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29309         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29310         CHECK_ACCESS(val_ptr);
29311         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29312         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29313         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29314 }
29315
29316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29317         LDKChannelDetails this_ptr_conv;
29318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29319         this_ptr_conv.is_owned = false;
29320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29321         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
29322         return ret_conv;
29323 }
29324
29325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29326         LDKChannelDetails this_ptr_conv;
29327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29328         this_ptr_conv.is_owned = false;
29329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29330         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
29331 }
29332
29333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29334         LDKChannelDetails this_ptr_conv;
29335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29336         this_ptr_conv.is_owned = false;
29337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29338         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29339         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
29340         int64_t ret_ref = (uintptr_t)ret_copy;
29341         return ret_ref;
29342 }
29343
29344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29345         LDKChannelDetails this_ptr_conv;
29346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29347         this_ptr_conv.is_owned = false;
29348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29349         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29350         CHECK_ACCESS(val_ptr);
29351         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29352         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29353         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
29354 }
29355
29356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29357         LDKChannelDetails this_ptr_conv;
29358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29359         this_ptr_conv.is_owned = false;
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29361         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
29362         return ret_conv;
29363 }
29364
29365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29366         LDKChannelDetails this_ptr_conv;
29367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29368         this_ptr_conv.is_owned = false;
29369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29370         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
29371 }
29372
29373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29374         LDKChannelDetails this_ptr_conv;
29375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29376         this_ptr_conv.is_owned = false;
29377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29378         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
29379         return ret_conv;
29380 }
29381
29382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29383         LDKChannelDetails this_ptr_conv;
29384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29385         this_ptr_conv.is_owned = false;
29386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29387         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
29388 }
29389
29390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29391         LDKChannelDetails this_ptr_conv;
29392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29393         this_ptr_conv.is_owned = false;
29394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29395         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
29396         return ret_conv;
29397 }
29398
29399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29400         LDKChannelDetails this_ptr_conv;
29401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29402         this_ptr_conv.is_owned = false;
29403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29404         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
29405 }
29406
29407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29408         LDKChannelDetails this_ptr_conv;
29409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29410         this_ptr_conv.is_owned = false;
29411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29412         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
29413         return ret_conv;
29414 }
29415
29416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29417         LDKChannelDetails this_ptr_conv;
29418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29419         this_ptr_conv.is_owned = false;
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29421         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
29422 }
29423
29424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29425         LDKChannelDetails this_ptr_conv;
29426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29427         this_ptr_conv.is_owned = false;
29428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29429         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
29430         return ret_conv;
29431 }
29432
29433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29434         LDKChannelDetails this_ptr_conv;
29435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29436         this_ptr_conv.is_owned = false;
29437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29438         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
29439 }
29440
29441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
29442         LDKChannelDetails this_ptr_conv;
29443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29444         this_ptr_conv.is_owned = false;
29445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29446         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29447         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
29448         int64_t ret_ref = (uintptr_t)ret_copy;
29449         return ret_ref;
29450 }
29451
29452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29453         LDKChannelDetails this_ptr_conv;
29454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29455         this_ptr_conv.is_owned = false;
29456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29457         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29458         CHECK_ACCESS(val_ptr);
29459         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29460         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
29461         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
29462 }
29463
29464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
29465         LDKChannelDetails this_ptr_conv;
29466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29467         this_ptr_conv.is_owned = false;
29468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29469         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
29470         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
29471         int64_t ret_ref = (uintptr_t)ret_copy;
29472         return ret_ref;
29473 }
29474
29475 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) {
29476         LDKChannelDetails this_ptr_conv;
29477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29478         this_ptr_conv.is_owned = false;
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29480         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29481         CHECK_ACCESS(val_ptr);
29482         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
29483         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
29484         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
29485 }
29486
29487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
29488         LDKChannelDetails this_ptr_conv;
29489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29490         this_ptr_conv.is_owned = false;
29491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29492         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
29493         return ret_conv;
29494 }
29495
29496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29497         LDKChannelDetails this_ptr_conv;
29498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29499         this_ptr_conv.is_owned = false;
29500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29501         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
29502 }
29503
29504 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
29505         LDKChannelDetails this_ptr_conv;
29506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29507         this_ptr_conv.is_owned = false;
29508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29509         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
29510         return ret_conv;
29511 }
29512
29513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29514         LDKChannelDetails this_ptr_conv;
29515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29516         this_ptr_conv.is_owned = false;
29517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29518         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
29519 }
29520
29521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
29522         LDKChannelDetails this_ptr_conv;
29523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29524         this_ptr_conv.is_owned = false;
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29526         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
29527         return ret_conv;
29528 }
29529
29530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29531         LDKChannelDetails this_ptr_conv;
29532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29533         this_ptr_conv.is_owned = false;
29534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29535         ChannelDetails_set_is_usable(&this_ptr_conv, val);
29536 }
29537
29538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
29539         LDKChannelDetails this_ptr_conv;
29540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29541         this_ptr_conv.is_owned = false;
29542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29543         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
29544         return ret_conv;
29545 }
29546
29547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29548         LDKChannelDetails this_ptr_conv;
29549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29550         this_ptr_conv.is_owned = false;
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29552         ChannelDetails_set_is_public(&this_ptr_conv, val);
29553 }
29554
29555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29556         LDKChannelDetails this_ptr_conv;
29557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29558         this_ptr_conv.is_owned = false;
29559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29560         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29561         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
29562         int64_t ret_ref = (uintptr_t)ret_copy;
29563         return ret_ref;
29564 }
29565
29566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29567         LDKChannelDetails this_ptr_conv;
29568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29569         this_ptr_conv.is_owned = false;
29570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29571         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29572         CHECK_ACCESS(val_ptr);
29573         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29574         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29575         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29576 }
29577
29578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29579         LDKChannelDetails this_ptr_conv;
29580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29581         this_ptr_conv.is_owned = false;
29582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29583         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29584         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
29585         int64_t ret_ref = (uintptr_t)ret_copy;
29586         return ret_ref;
29587 }
29588
29589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29590         LDKChannelDetails this_ptr_conv;
29591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29592         this_ptr_conv.is_owned = false;
29593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29594         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29595         CHECK_ACCESS(val_ptr);
29596         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29597         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29598         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29599 }
29600
29601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29602         LDKChannelDetails this_ptr_conv;
29603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29604         this_ptr_conv.is_owned = false;
29605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29606         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
29607         int64_t ret_ref = 0;
29608         if ((uintptr_t)ret_var.inner > 4096) {
29609                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29610                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29612                 ret_ref = (uintptr_t)ret_var.inner;
29613                 if (ret_var.is_owned) {
29614                         ret_ref |= 1;
29615                 }
29616         }
29617         return ret_ref;
29618 }
29619
29620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29621         LDKChannelDetails this_ptr_conv;
29622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29623         this_ptr_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29625         LDKChannelConfig val_conv;
29626         val_conv.inner = (void*)(val & (~1));
29627         val_conv.is_owned = (val & 1) || (val == 0);
29628         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29629         val_conv = ChannelConfig_clone(&val_conv);
29630         ChannelDetails_set_config(&this_ptr_conv, val_conv);
29631 }
29632
29633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
29634         LDKThirtyTwoBytes channel_id_arg_ref;
29635         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29636         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29637         LDKChannelCounterparty counterparty_arg_conv;
29638         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
29639         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
29640         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
29641         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
29642         LDKOutPoint funding_txo_arg_conv;
29643         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
29644         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
29646         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
29647         LDKChannelTypeFeatures channel_type_arg_conv;
29648         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
29649         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
29651         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
29652         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
29653         CHECK_ACCESS(short_channel_id_arg_ptr);
29654         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
29655         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
29656         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
29657         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
29658         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
29659         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
29660         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
29661         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
29662         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
29663         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
29664         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
29665         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
29666         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
29667         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
29668         CHECK_ACCESS(confirmations_required_arg_ptr);
29669         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
29670         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
29671         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
29672         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
29673         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
29674         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
29675         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
29676         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
29677         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
29678         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
29679         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
29680         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
29681         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
29682         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
29683         LDKChannelConfig config_arg_conv;
29684         config_arg_conv.inner = (void*)(config_arg & (~1));
29685         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
29686         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
29687         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
29688         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
29689         int64_t ret_ref = 0;
29690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29693         ret_ref = (uintptr_t)ret_var.inner;
29694         if (ret_var.is_owned) {
29695                 ret_ref |= 1;
29696         }
29697         return ret_ref;
29698 }
29699
29700 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
29701         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
29702 int64_t ret_ref = 0;
29703 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29704 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29705 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29706 ret_ref = (uintptr_t)ret_var.inner;
29707 if (ret_var.is_owned) {
29708         ret_ref |= 1;
29709 }
29710         return ret_ref;
29711 }
29712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29713         LDKChannelDetails arg_conv;
29714         arg_conv.inner = (void*)(arg & (~1));
29715         arg_conv.is_owned = false;
29716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29717         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
29718         return ret_conv;
29719 }
29720
29721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29722         LDKChannelDetails orig_conv;
29723         orig_conv.inner = (void*)(orig & (~1));
29724         orig_conv.is_owned = false;
29725         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29726         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
29727         int64_t ret_ref = 0;
29728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29731         ret_ref = (uintptr_t)ret_var.inner;
29732         if (ret_var.is_owned) {
29733                 ret_ref |= 1;
29734         }
29735         return ret_ref;
29736 }
29737
29738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29739         LDKChannelDetails this_arg_conv;
29740         this_arg_conv.inner = (void*)(this_arg & (~1));
29741         this_arg_conv.is_owned = false;
29742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29743         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29744         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
29745         int64_t ret_ref = (uintptr_t)ret_copy;
29746         return ret_ref;
29747 }
29748
29749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29750         LDKChannelDetails this_arg_conv;
29751         this_arg_conv.inner = (void*)(this_arg & (~1));
29752         this_arg_conv.is_owned = false;
29753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29754         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29755         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
29756         int64_t ret_ref = (uintptr_t)ret_copy;
29757         return ret_ref;
29758 }
29759
29760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29761         if ((this_ptr & 1) != 0) return;
29762         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29763         CHECK_ACCESS(this_ptr_ptr);
29764         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
29765         FREE((void*)this_ptr);
29766         PaymentSendFailure_free(this_ptr_conv);
29767 }
29768
29769 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
29770         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29771         *ret_copy = PaymentSendFailure_clone(arg);
29772 int64_t ret_ref = (uintptr_t)ret_copy;
29773         return ret_ref;
29774 }
29775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29776         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
29777         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
29778         return ret_conv;
29779 }
29780
29781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29782         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
29783         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29784         *ret_copy = PaymentSendFailure_clone(orig_conv);
29785         int64_t ret_ref = (uintptr_t)ret_copy;
29786         return ret_ref;
29787 }
29788
29789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
29790         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
29791         CHECK_ACCESS(a_ptr);
29792         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
29793         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
29794         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29795         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
29796         int64_t ret_ref = (uintptr_t)ret_copy;
29797         return ret_ref;
29798 }
29799
29800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
29801         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
29802         a_constr.datalen = (*env)->GetArrayLength(env, a);
29803         if (a_constr.datalen > 0)
29804                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29805         else
29806                 a_constr.data = NULL;
29807         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29808         for (size_t w = 0; w < a_constr.datalen; w++) {
29809                 int64_t a_conv_22 = a_vals[w];
29810                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
29811                 CHECK_ACCESS(a_conv_22_ptr);
29812                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
29813                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
29814                 a_constr.data[w] = a_conv_22_conv;
29815         }
29816         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29817         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29818         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
29819         int64_t ret_ref = (uintptr_t)ret_copy;
29820         return ret_ref;
29821 }
29822
29823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
29824         LDKCVec_APIErrorZ a_constr;
29825         a_constr.datalen = (*env)->GetArrayLength(env, a);
29826         if (a_constr.datalen > 0)
29827                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
29828         else
29829                 a_constr.data = NULL;
29830         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29831         for (size_t k = 0; k < a_constr.datalen; k++) {
29832                 int64_t a_conv_10 = a_vals[k];
29833                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
29834                 CHECK_ACCESS(a_conv_10_ptr);
29835                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
29836                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
29837                 a_constr.data[k] = a_conv_10_conv;
29838         }
29839         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29840         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29841         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
29842         int64_t ret_ref = (uintptr_t)ret_copy;
29843         return ret_ref;
29844 }
29845
29846 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) {
29847         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
29848         results_constr.datalen = (*env)->GetArrayLength(env, results);
29849         if (results_constr.datalen > 0)
29850                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29851         else
29852                 results_constr.data = NULL;
29853         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
29854         for (size_t w = 0; w < results_constr.datalen; w++) {
29855                 int64_t results_conv_22 = results_vals[w];
29856                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
29857                 CHECK_ACCESS(results_conv_22_ptr);
29858                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
29859                 results_constr.data[w] = results_conv_22_conv;
29860         }
29861         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
29862         LDKRouteParameters failed_paths_retry_conv;
29863         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
29864         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
29865         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
29866         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
29867         LDKThirtyTwoBytes payment_id_ref;
29868         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29869         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29870         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29871         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
29872         int64_t ret_ref = (uintptr_t)ret_copy;
29873         return ret_ref;
29874 }
29875
29876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29877         LDKPhantomRouteHints this_obj_conv;
29878         this_obj_conv.inner = (void*)(this_obj & (~1));
29879         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29881         PhantomRouteHints_free(this_obj_conv);
29882 }
29883
29884 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
29885         LDKPhantomRouteHints this_ptr_conv;
29886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29887         this_ptr_conv.is_owned = false;
29888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29889         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
29890         int64_tArray ret_arr = NULL;
29891         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29892         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29893         for (size_t q = 0; q < ret_var.datalen; q++) {
29894                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29895                 int64_t ret_conv_16_ref = 0;
29896                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29897                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29898                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29899                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29900                 if (ret_conv_16_var.is_owned) {
29901                         ret_conv_16_ref |= 1;
29902                 }
29903                 ret_arr_ptr[q] = ret_conv_16_ref;
29904         }
29905         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29906         FREE(ret_var.data);
29907         return ret_arr;
29908 }
29909
29910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29911         LDKPhantomRouteHints this_ptr_conv;
29912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29913         this_ptr_conv.is_owned = false;
29914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29915         LDKCVec_ChannelDetailsZ val_constr;
29916         val_constr.datalen = (*env)->GetArrayLength(env, val);
29917         if (val_constr.datalen > 0)
29918                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29919         else
29920                 val_constr.data = NULL;
29921         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29922         for (size_t q = 0; q < val_constr.datalen; q++) {
29923                 int64_t val_conv_16 = val_vals[q];
29924                 LDKChannelDetails val_conv_16_conv;
29925                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
29926                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
29927                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
29928                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
29929                 val_constr.data[q] = val_conv_16_conv;
29930         }
29931         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29932         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
29933 }
29934
29935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29936         LDKPhantomRouteHints this_ptr_conv;
29937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29938         this_ptr_conv.is_owned = false;
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29940         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
29941         return ret_conv;
29942 }
29943
29944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29945         LDKPhantomRouteHints this_ptr_conv;
29946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29947         this_ptr_conv.is_owned = false;
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29949         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
29950 }
29951
29952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29953         LDKPhantomRouteHints this_ptr_conv;
29954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29955         this_ptr_conv.is_owned = false;
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29957         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
29959         return ret_arr;
29960 }
29961
29962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29963         LDKPhantomRouteHints this_ptr_conv;
29964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29965         this_ptr_conv.is_owned = false;
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29967         LDKPublicKey val_ref;
29968         CHECK((*env)->GetArrayLength(env, val) == 33);
29969         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29970         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
29971 }
29972
29973 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) {
29974         LDKCVec_ChannelDetailsZ channels_arg_constr;
29975         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
29976         if (channels_arg_constr.datalen > 0)
29977                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29978         else
29979                 channels_arg_constr.data = NULL;
29980         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
29981         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
29982                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
29983                 LDKChannelDetails channels_arg_conv_16_conv;
29984                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
29985                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
29986                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
29987                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
29988                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
29989         }
29990         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
29991         LDKPublicKey real_node_pubkey_arg_ref;
29992         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
29993         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
29994         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
29995         int64_t ret_ref = 0;
29996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29999         ret_ref = (uintptr_t)ret_var.inner;
30000         if (ret_var.is_owned) {
30001                 ret_ref |= 1;
30002         }
30003         return ret_ref;
30004 }
30005
30006 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
30007         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
30008 int64_t ret_ref = 0;
30009 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30010 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30011 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30012 ret_ref = (uintptr_t)ret_var.inner;
30013 if (ret_var.is_owned) {
30014         ret_ref |= 1;
30015 }
30016         return ret_ref;
30017 }
30018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30019         LDKPhantomRouteHints arg_conv;
30020         arg_conv.inner = (void*)(arg & (~1));
30021         arg_conv.is_owned = false;
30022         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30023         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
30024         return ret_conv;
30025 }
30026
30027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30028         LDKPhantomRouteHints orig_conv;
30029         orig_conv.inner = (void*)(orig & (~1));
30030         orig_conv.is_owned = false;
30031         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30032         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
30033         int64_t ret_ref = 0;
30034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30037         ret_ref = (uintptr_t)ret_var.inner;
30038         if (ret_var.is_owned) {
30039                 ret_ref |= 1;
30040         }
30041         return ret_ref;
30042 }
30043
30044 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) {
30045         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
30046         CHECK_ACCESS(fee_est_ptr);
30047         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
30048         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
30049                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30050                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
30051         }
30052         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30053         CHECK_ACCESS(chain_monitor_ptr);
30054         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30055         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30057                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30058         }
30059         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30060         CHECK_ACCESS(tx_broadcaster_ptr);
30061         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30062         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30063                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30064                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30065         }
30066         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30067         CHECK_ACCESS(logger_ptr);
30068         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30069         if (logger_conv.free == LDKLogger_JCalls_free) {
30070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30071                 LDKLogger_JCalls_cloned(&logger_conv);
30072         }
30073         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30074         CHECK_ACCESS(keys_manager_ptr);
30075         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30076         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30077                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30078                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30079         }
30080         LDKUserConfig config_conv;
30081         config_conv.inner = (void*)(config & (~1));
30082         config_conv.is_owned = (config & 1) || (config == 0);
30083         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30084         config_conv = UserConfig_clone(&config_conv);
30085         LDKChainParameters params_conv;
30086         params_conv.inner = (void*)(params & (~1));
30087         params_conv.is_owned = (params & 1) || (params == 0);
30088         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
30089         params_conv = ChainParameters_clone(&params_conv);
30090         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
30091         int64_t ret_ref = 0;
30092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30095         ret_ref = (uintptr_t)ret_var.inner;
30096         if (ret_var.is_owned) {
30097                 ret_ref |= 1;
30098         }
30099         return ret_ref;
30100 }
30101
30102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
30103         LDKChannelManager this_arg_conv;
30104         this_arg_conv.inner = (void*)(this_arg & (~1));
30105         this_arg_conv.is_owned = false;
30106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30107         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
30108         int64_t ret_ref = 0;
30109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30112         ret_ref = (uintptr_t)ret_var.inner;
30113         if (ret_var.is_owned) {
30114                 ret_ref |= 1;
30115         }
30116         return ret_ref;
30117 }
30118
30119 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) {
30120         LDKChannelManager this_arg_conv;
30121         this_arg_conv.inner = (void*)(this_arg & (~1));
30122         this_arg_conv.is_owned = false;
30123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30124         LDKPublicKey their_network_key_ref;
30125         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
30126         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
30127         LDKUserConfig override_config_conv;
30128         override_config_conv.inner = (void*)(override_config & (~1));
30129         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
30130         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
30131         override_config_conv = UserConfig_clone(&override_config_conv);
30132         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
30133         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
30134         return (int64_t)ret_conv;
30135 }
30136
30137 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30138         LDKChannelManager this_arg_conv;
30139         this_arg_conv.inner = (void*)(this_arg & (~1));
30140         this_arg_conv.is_owned = false;
30141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30142         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
30143         int64_tArray ret_arr = NULL;
30144         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30145         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30146         for (size_t q = 0; q < ret_var.datalen; q++) {
30147                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30148                 int64_t ret_conv_16_ref = 0;
30149                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30150                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30151                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30152                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30153                 if (ret_conv_16_var.is_owned) {
30154                         ret_conv_16_ref |= 1;
30155                 }
30156                 ret_arr_ptr[q] = ret_conv_16_ref;
30157         }
30158         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30159         FREE(ret_var.data);
30160         return ret_arr;
30161 }
30162
30163 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30164         LDKChannelManager this_arg_conv;
30165         this_arg_conv.inner = (void*)(this_arg & (~1));
30166         this_arg_conv.is_owned = false;
30167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30168         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
30169         int64_tArray ret_arr = NULL;
30170         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30171         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30172         for (size_t q = 0; q < ret_var.datalen; q++) {
30173                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30174                 int64_t ret_conv_16_ref = 0;
30175                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30176                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30177                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30178                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30179                 if (ret_conv_16_var.is_owned) {
30180                         ret_conv_16_ref |= 1;
30181                 }
30182                 ret_arr_ptr[q] = ret_conv_16_ref;
30183         }
30184         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30185         FREE(ret_var.data);
30186         return ret_arr;
30187 }
30188
30189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30190         LDKChannelManager this_arg_conv;
30191         this_arg_conv.inner = (void*)(this_arg & (~1));
30192         this_arg_conv.is_owned = false;
30193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30194         unsigned char channel_id_arr[32];
30195         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30196         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30197         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30198         LDKPublicKey counterparty_node_id_ref;
30199         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30200         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30201         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30202         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30203         return (int64_t)ret_conv;
30204 }
30205
30206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
30207         LDKChannelManager this_arg_conv;
30208         this_arg_conv.inner = (void*)(this_arg & (~1));
30209         this_arg_conv.is_owned = false;
30210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30211         unsigned char channel_id_arr[32];
30212         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30213         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30214         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30215         LDKPublicKey counterparty_node_id_ref;
30216         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30217         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30218         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30219         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
30220         return (int64_t)ret_conv;
30221 }
30222
30223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30224         LDKChannelManager this_arg_conv;
30225         this_arg_conv.inner = (void*)(this_arg & (~1));
30226         this_arg_conv.is_owned = false;
30227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30228         unsigned char channel_id_arr[32];
30229         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30230         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30231         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30232         LDKPublicKey counterparty_node_id_ref;
30233         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30234         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30235         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30236         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30237         return (int64_t)ret_conv;
30238 }
30239
30240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30241         LDKChannelManager this_arg_conv;
30242         this_arg_conv.inner = (void*)(this_arg & (~1));
30243         this_arg_conv.is_owned = false;
30244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30245         unsigned char channel_id_arr[32];
30246         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30247         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30248         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30249         LDKPublicKey counterparty_node_id_ref;
30250         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30251         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30252         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30253         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30254         return (int64_t)ret_conv;
30255 }
30256
30257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30258         LDKChannelManager this_arg_conv;
30259         this_arg_conv.inner = (void*)(this_arg & (~1));
30260         this_arg_conv.is_owned = false;
30261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30262         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
30263 }
30264
30265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30266         LDKChannelManager this_arg_conv;
30267         this_arg_conv.inner = (void*)(this_arg & (~1));
30268         this_arg_conv.is_owned = false;
30269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30270         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
30271 }
30272
30273 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) {
30274         LDKChannelManager this_arg_conv;
30275         this_arg_conv.inner = (void*)(this_arg & (~1));
30276         this_arg_conv.is_owned = false;
30277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30278         LDKRoute route_conv;
30279         route_conv.inner = (void*)(route & (~1));
30280         route_conv.is_owned = false;
30281         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30282         LDKThirtyTwoBytes payment_hash_ref;
30283         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30284         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30285         LDKThirtyTwoBytes payment_secret_ref;
30286         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30287         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30288         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
30289         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
30290         return (int64_t)ret_conv;
30291 }
30292
30293 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) {
30294         LDKChannelManager this_arg_conv;
30295         this_arg_conv.inner = (void*)(this_arg & (~1));
30296         this_arg_conv.is_owned = false;
30297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30298         LDKRoute route_conv;
30299         route_conv.inner = (void*)(route & (~1));
30300         route_conv.is_owned = false;
30301         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30302         LDKThirtyTwoBytes payment_id_ref;
30303         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30304         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30305         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
30306         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
30307         return (int64_t)ret_conv;
30308 }
30309
30310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
30311         LDKChannelManager this_arg_conv;
30312         this_arg_conv.inner = (void*)(this_arg & (~1));
30313         this_arg_conv.is_owned = false;
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30315         LDKThirtyTwoBytes payment_id_ref;
30316         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30317         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30318         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
30319 }
30320
30321 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) {
30322         LDKChannelManager this_arg_conv;
30323         this_arg_conv.inner = (void*)(this_arg & (~1));
30324         this_arg_conv.is_owned = false;
30325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30326         LDKRoute route_conv;
30327         route_conv.inner = (void*)(route & (~1));
30328         route_conv.is_owned = false;
30329         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30330         LDKThirtyTwoBytes payment_preimage_ref;
30331         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30332         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30333         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
30334         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
30335         return (int64_t)ret_conv;
30336 }
30337
30338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
30339         LDKChannelManager this_arg_conv;
30340         this_arg_conv.inner = (void*)(this_arg & (~1));
30341         this_arg_conv.is_owned = false;
30342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30343         unsigned char temporary_channel_id_arr[32];
30344         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30345         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30346         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30347         LDKPublicKey counterparty_node_id_ref;
30348         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30349         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30350         LDKTransaction funding_transaction_ref;
30351         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
30352         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
30353         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
30354         funding_transaction_ref.data_is_owned = true;
30355         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30356         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
30357         return (int64_t)ret_conv;
30358 }
30359
30360 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) {
30361         LDKChannelManager this_arg_conv;
30362         this_arg_conv.inner = (void*)(this_arg & (~1));
30363         this_arg_conv.is_owned = false;
30364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30365         LDKThreeBytes rgb_ref;
30366         CHECK((*env)->GetArrayLength(env, rgb) == 3);
30367         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
30368         LDKThirtyTwoBytes alias_ref;
30369         CHECK((*env)->GetArrayLength(env, alias) == 32);
30370         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
30371         LDKCVec_NetAddressZ addresses_constr;
30372         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
30373         if (addresses_constr.datalen > 0)
30374                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30375         else
30376                 addresses_constr.data = NULL;
30377         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
30378         for (size_t m = 0; m < addresses_constr.datalen; m++) {
30379                 int64_t addresses_conv_12 = addresses_vals[m];
30380                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
30381                 CHECK_ACCESS(addresses_conv_12_ptr);
30382                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
30383                 addresses_constr.data[m] = addresses_conv_12_conv;
30384         }
30385         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
30386         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
30387 }
30388
30389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1channel_1config(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id, jobjectArray channel_ids, int64_t config) {
30390         LDKChannelManager this_arg_conv;
30391         this_arg_conv.inner = (void*)(this_arg & (~1));
30392         this_arg_conv.is_owned = false;
30393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30394         LDKPublicKey counterparty_node_id_ref;
30395         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30396         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30397         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
30398         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
30399         if (channel_ids_constr.datalen > 0)
30400                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
30401         else
30402                 channel_ids_constr.data = NULL;
30403         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
30404                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
30405                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
30406                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
30407                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
30408                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
30409         }
30410         LDKChannelConfig config_conv;
30411         config_conv.inner = (void*)(config & (~1));
30412         config_conv.is_owned = false;
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30414         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30415         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
30416         return (int64_t)ret_conv;
30417 }
30418
30419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
30420         LDKChannelManager this_arg_conv;
30421         this_arg_conv.inner = (void*)(this_arg & (~1));
30422         this_arg_conv.is_owned = false;
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30424         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
30425 }
30426
30427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
30428         LDKChannelManager this_arg_conv;
30429         this_arg_conv.inner = (void*)(this_arg & (~1));
30430         this_arg_conv.is_owned = false;
30431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30432         ChannelManager_timer_tick_occurred(&this_arg_conv);
30433 }
30434
30435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
30436         LDKChannelManager this_arg_conv;
30437         this_arg_conv.inner = (void*)(this_arg & (~1));
30438         this_arg_conv.is_owned = false;
30439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30440         unsigned char payment_hash_arr[32];
30441         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30442         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
30443         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
30444         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
30445 }
30446
30447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
30448         LDKChannelManager this_arg_conv;
30449         this_arg_conv.inner = (void*)(this_arg & (~1));
30450         this_arg_conv.is_owned = false;
30451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30452         LDKThirtyTwoBytes payment_preimage_ref;
30453         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30454         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30455         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
30456 }
30457
30458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30459         LDKChannelManager this_arg_conv;
30460         this_arg_conv.inner = (void*)(this_arg & (~1));
30461         this_arg_conv.is_owned = false;
30462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30463         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
30465         return ret_arr;
30466 }
30467
30468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
30469         LDKChannelManager this_arg_conv;
30470         this_arg_conv.inner = (void*)(this_arg & (~1));
30471         this_arg_conv.is_owned = false;
30472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30473         unsigned char temporary_channel_id_arr[32];
30474         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30475         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30476         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30477         LDKPublicKey counterparty_node_id_ref;
30478         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30479         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30480         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30481         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
30482         return (int64_t)ret_conv;
30483 }
30484
30485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel_1from_1trusted_1peer_10conf(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
30486         LDKChannelManager this_arg_conv;
30487         this_arg_conv.inner = (void*)(this_arg & (~1));
30488         this_arg_conv.is_owned = false;
30489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30490         unsigned char temporary_channel_id_arr[32];
30491         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30492         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30493         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30494         LDKPublicKey counterparty_node_id_ref;
30495         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30496         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30497         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30498         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
30499         return (int64_t)ret_conv;
30500 }
30501
30502 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) {
30503         LDKChannelManager this_arg_conv;
30504         this_arg_conv.inner = (void*)(this_arg & (~1));
30505         this_arg_conv.is_owned = false;
30506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30507         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30508         CHECK_ACCESS(min_value_msat_ptr);
30509         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30510         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30511         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
30512         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
30513         return (int64_t)ret_conv;
30514 }
30515
30516 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) {
30517         LDKChannelManager this_arg_conv;
30518         this_arg_conv.inner = (void*)(this_arg & (~1));
30519         this_arg_conv.is_owned = false;
30520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30521         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30522         CHECK_ACCESS(min_value_msat_ptr);
30523         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30524         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30525         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
30526         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
30527         return (int64_t)ret_conv;
30528 }
30529
30530 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) {
30531         LDKChannelManager this_arg_conv;
30532         this_arg_conv.inner = (void*)(this_arg & (~1));
30533         this_arg_conv.is_owned = false;
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30535         LDKThirtyTwoBytes payment_hash_ref;
30536         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30537         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30538         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30539         CHECK_ACCESS(min_value_msat_ptr);
30540         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30541         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30542         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
30543         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
30544         return (int64_t)ret_conv;
30545 }
30546
30547 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) {
30548         LDKChannelManager this_arg_conv;
30549         this_arg_conv.inner = (void*)(this_arg & (~1));
30550         this_arg_conv.is_owned = false;
30551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30552         LDKThirtyTwoBytes payment_hash_ref;
30553         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30554         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30555         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30556         CHECK_ACCESS(min_value_msat_ptr);
30557         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30558         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30559         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
30560         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
30561         return (int64_t)ret_conv;
30562 }
30563
30564 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) {
30565         LDKChannelManager this_arg_conv;
30566         this_arg_conv.inner = (void*)(this_arg & (~1));
30567         this_arg_conv.is_owned = false;
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30569         LDKThirtyTwoBytes payment_hash_ref;
30570         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30571         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30572         LDKThirtyTwoBytes payment_secret_ref;
30573         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30574         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30575         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
30576         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
30577         return (int64_t)ret_conv;
30578 }
30579
30580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30581         LDKChannelManager this_arg_conv;
30582         this_arg_conv.inner = (void*)(this_arg & (~1));
30583         this_arg_conv.is_owned = false;
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30585         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
30586         return ret_conv;
30587 }
30588
30589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
30590         LDKChannelManager this_arg_conv;
30591         this_arg_conv.inner = (void*)(this_arg & (~1));
30592         this_arg_conv.is_owned = false;
30593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30594         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
30595         int64_t ret_ref = 0;
30596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30599         ret_ref = (uintptr_t)ret_var.inner;
30600         if (ret_var.is_owned) {
30601                 ret_ref |= 1;
30602         }
30603         return ret_ref;
30604 }
30605
30606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
30607         LDKChannelManager this_arg_conv;
30608         this_arg_conv.inner = (void*)(this_arg & (~1));
30609         this_arg_conv.is_owned = false;
30610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30611         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
30612         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
30613         return (int64_t)ret_ret;
30614 }
30615
30616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
30617         LDKChannelManager this_arg_conv;
30618         this_arg_conv.inner = (void*)(this_arg & (~1));
30619         this_arg_conv.is_owned = false;
30620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30621         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
30622         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
30623         return (int64_t)ret_ret;
30624 }
30625
30626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
30627         LDKChannelManager this_arg_conv;
30628         this_arg_conv.inner = (void*)(this_arg & (~1));
30629         this_arg_conv.is_owned = false;
30630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30631         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
30632         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
30633         return (int64_t)ret_ret;
30634 }
30635
30636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
30637         LDKChannelManager this_arg_conv;
30638         this_arg_conv.inner = (void*)(this_arg & (~1));
30639         this_arg_conv.is_owned = false;
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30641         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
30642         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
30643         return (int64_t)ret_ret;
30644 }
30645
30646 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) {
30647         LDKChannelManager this_arg_conv;
30648         this_arg_conv.inner = (void*)(this_arg & (~1));
30649         this_arg_conv.is_owned = false;
30650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30651         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
30652         return ret_conv;
30653 }
30654
30655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
30656         LDKChannelManager this_arg_conv;
30657         this_arg_conv.inner = (void*)(this_arg & (~1));
30658         this_arg_conv.is_owned = false;
30659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30660         ChannelManager_await_persistable_update(&this_arg_conv);
30661 }
30662
30663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
30664         LDKChannelManager this_arg_conv;
30665         this_arg_conv.inner = (void*)(this_arg & (~1));
30666         this_arg_conv.is_owned = false;
30667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30668         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
30669         int64_t ret_ref = 0;
30670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30673         ret_ref = (uintptr_t)ret_var.inner;
30674         if (ret_var.is_owned) {
30675                 ret_ref |= 1;
30676         }
30677         return ret_ref;
30678 }
30679
30680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
30681         LDKChannelManager this_arg_conv;
30682         this_arg_conv.inner = (void*)(this_arg & (~1));
30683         this_arg_conv.is_owned = false;
30684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30685         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
30686         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
30687         return (int64_t)ret_ret;
30688 }
30689
30690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
30691         LDKCounterpartyForwardingInfo obj_conv;
30692         obj_conv.inner = (void*)(obj & (~1));
30693         obj_conv.is_owned = false;
30694         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30695         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
30696         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30697         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30698         CVec_u8Z_free(ret_var);
30699         return ret_arr;
30700 }
30701
30702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30703         LDKu8slice ser_ref;
30704         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30705         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30706         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
30707         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
30708         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30709         return (int64_t)ret_conv;
30710 }
30711
30712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
30713         LDKChannelCounterparty obj_conv;
30714         obj_conv.inner = (void*)(obj & (~1));
30715         obj_conv.is_owned = false;
30716         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30717         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
30718         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30719         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30720         CVec_u8Z_free(ret_var);
30721         return ret_arr;
30722 }
30723
30724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30725         LDKu8slice ser_ref;
30726         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30727         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30728         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
30729         *ret_conv = ChannelCounterparty_read(ser_ref);
30730         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30731         return (int64_t)ret_conv;
30732 }
30733
30734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
30735         LDKChannelDetails obj_conv;
30736         obj_conv.inner = (void*)(obj & (~1));
30737         obj_conv.is_owned = false;
30738         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30739         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
30740         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30741         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30742         CVec_u8Z_free(ret_var);
30743         return ret_arr;
30744 }
30745
30746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30747         LDKu8slice ser_ref;
30748         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30749         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30750         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
30751         *ret_conv = ChannelDetails_read(ser_ref);
30752         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30753         return (int64_t)ret_conv;
30754 }
30755
30756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
30757         LDKPhantomRouteHints obj_conv;
30758         obj_conv.inner = (void*)(obj & (~1));
30759         obj_conv.is_owned = false;
30760         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30761         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
30762         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30763         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30764         CVec_u8Z_free(ret_var);
30765         return ret_arr;
30766 }
30767
30768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30769         LDKu8slice ser_ref;
30770         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30771         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30772         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
30773         *ret_conv = PhantomRouteHints_read(ser_ref);
30774         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30775         return (int64_t)ret_conv;
30776 }
30777
30778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
30779         LDKChannelManager obj_conv;
30780         obj_conv.inner = (void*)(obj & (~1));
30781         obj_conv.is_owned = false;
30782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30783         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
30784         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30785         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30786         CVec_u8Z_free(ret_var);
30787         return ret_arr;
30788 }
30789
30790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30791         LDKChannelManagerReadArgs this_obj_conv;
30792         this_obj_conv.inner = (void*)(this_obj & (~1));
30793         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30795         ChannelManagerReadArgs_free(this_obj_conv);
30796 }
30797
30798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
30799         LDKChannelManagerReadArgs this_ptr_conv;
30800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30801         this_ptr_conv.is_owned = false;
30802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30803         // WARNING: This object doesn't live past this scope, needs clone!
30804         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
30805         return ret_ret;
30806 }
30807
30808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30809         LDKChannelManagerReadArgs this_ptr_conv;
30810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30811         this_ptr_conv.is_owned = false;
30812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30813         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30814         CHECK_ACCESS(val_ptr);
30815         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
30816         if (val_conv.free == LDKKeysInterface_JCalls_free) {
30817                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30818                 LDKKeysInterface_JCalls_cloned(&val_conv);
30819         }
30820         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
30821 }
30822
30823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
30824         LDKChannelManagerReadArgs this_ptr_conv;
30825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30826         this_ptr_conv.is_owned = false;
30827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30828         // WARNING: This object doesn't live past this scope, needs clone!
30829         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
30830         return ret_ret;
30831 }
30832
30833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30834         LDKChannelManagerReadArgs this_ptr_conv;
30835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30836         this_ptr_conv.is_owned = false;
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30838         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30839         CHECK_ACCESS(val_ptr);
30840         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
30841         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
30842                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30843                 LDKFeeEstimator_JCalls_cloned(&val_conv);
30844         }
30845         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
30846 }
30847
30848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
30849         LDKChannelManagerReadArgs this_ptr_conv;
30850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30851         this_ptr_conv.is_owned = false;
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30853         // WARNING: This object doesn't live past this scope, needs clone!
30854         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
30855         return ret_ret;
30856 }
30857
30858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30859         LDKChannelManagerReadArgs this_ptr_conv;
30860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30861         this_ptr_conv.is_owned = false;
30862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30863         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30864         CHECK_ACCESS(val_ptr);
30865         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
30866         if (val_conv.free == LDKWatch_JCalls_free) {
30867                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30868                 LDKWatch_JCalls_cloned(&val_conv);
30869         }
30870         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
30871 }
30872
30873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
30874         LDKChannelManagerReadArgs this_ptr_conv;
30875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30876         this_ptr_conv.is_owned = false;
30877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30878         // WARNING: This object doesn't live past this scope, needs clone!
30879         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
30880         return ret_ret;
30881 }
30882
30883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30884         LDKChannelManagerReadArgs this_ptr_conv;
30885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30886         this_ptr_conv.is_owned = false;
30887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30888         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30889         CHECK_ACCESS(val_ptr);
30890         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
30891         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
30892                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30893                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
30894         }
30895         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
30896 }
30897
30898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
30899         LDKChannelManagerReadArgs this_ptr_conv;
30900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30901         this_ptr_conv.is_owned = false;
30902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30903         // WARNING: This object doesn't live past this scope, needs clone!
30904         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
30905         return ret_ret;
30906 }
30907
30908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30909         LDKChannelManagerReadArgs this_ptr_conv;
30910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30911         this_ptr_conv.is_owned = false;
30912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30913         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30914         CHECK_ACCESS(val_ptr);
30915         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
30916         if (val_conv.free == LDKLogger_JCalls_free) {
30917                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30918                 LDKLogger_JCalls_cloned(&val_conv);
30919         }
30920         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
30921 }
30922
30923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30924         LDKChannelManagerReadArgs this_ptr_conv;
30925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30926         this_ptr_conv.is_owned = false;
30927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30928         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
30929         int64_t ret_ref = 0;
30930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30933         ret_ref = (uintptr_t)ret_var.inner;
30934         if (ret_var.is_owned) {
30935                 ret_ref |= 1;
30936         }
30937         return ret_ref;
30938 }
30939
30940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30941         LDKChannelManagerReadArgs this_ptr_conv;
30942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30943         this_ptr_conv.is_owned = false;
30944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30945         LDKUserConfig val_conv;
30946         val_conv.inner = (void*)(val & (~1));
30947         val_conv.is_owned = (val & 1) || (val == 0);
30948         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30949         val_conv = UserConfig_clone(&val_conv);
30950         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
30951 }
30952
30953 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) {
30954         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30955         CHECK_ACCESS(keys_manager_ptr);
30956         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30957         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30959                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30960         }
30961         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
30962         CHECK_ACCESS(fee_estimator_ptr);
30963         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30964         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30965                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30966                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30967         }
30968         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30969         CHECK_ACCESS(chain_monitor_ptr);
30970         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30971         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30972                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30973                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30974         }
30975         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30976         CHECK_ACCESS(tx_broadcaster_ptr);
30977         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30978         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30980                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30981         }
30982         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30983         CHECK_ACCESS(logger_ptr);
30984         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30985         if (logger_conv.free == LDKLogger_JCalls_free) {
30986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30987                 LDKLogger_JCalls_cloned(&logger_conv);
30988         }
30989         LDKUserConfig default_config_conv;
30990         default_config_conv.inner = (void*)(default_config & (~1));
30991         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
30992         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
30993         default_config_conv = UserConfig_clone(&default_config_conv);
30994         LDKCVec_ChannelMonitorZ channel_monitors_constr;
30995         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
30996         if (channel_monitors_constr.datalen > 0)
30997                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
30998         else
30999                 channel_monitors_constr.data = NULL;
31000         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
31001         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
31002                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
31003                 LDKChannelMonitor channel_monitors_conv_16_conv;
31004                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
31005                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
31006                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
31007                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
31008         }
31009         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
31010         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);
31011         int64_t ret_ref = 0;
31012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31015         ret_ref = (uintptr_t)ret_var.inner;
31016         if (ret_var.is_owned) {
31017                 ret_ref |= 1;
31018         }
31019         return ret_ref;
31020 }
31021
31022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31023         LDKu8slice ser_ref;
31024         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31025         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31026         LDKChannelManagerReadArgs arg_conv;
31027         arg_conv.inner = (void*)(arg & (~1));
31028         arg_conv.is_owned = (arg & 1) || (arg == 0);
31029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31030         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
31031         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
31032         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
31033         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31034         return (int64_t)ret_conv;
31035 }
31036
31037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31038         LDKExpandedKey this_obj_conv;
31039         this_obj_conv.inner = (void*)(this_obj & (~1));
31040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31042         ExpandedKey_free(this_obj_conv);
31043 }
31044
31045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
31046         unsigned char key_material_arr[32];
31047         CHECK((*env)->GetArrayLength(env, key_material) == 32);
31048         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
31049         unsigned char (*key_material_ref)[32] = &key_material_arr;
31050         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
31051         int64_t ret_ref = 0;
31052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31055         ret_ref = (uintptr_t)ret_var.inner;
31056         if (ret_var.is_owned) {
31057                 ret_ref |= 1;
31058         }
31059         return ret_ref;
31060 }
31061
31062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t keys_manager, int64_t current_time) {
31063         LDKExpandedKey keys_conv;
31064         keys_conv.inner = (void*)(keys & (~1));
31065         keys_conv.is_owned = false;
31066         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31067         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31068         CHECK_ACCESS(min_value_msat_ptr);
31069         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31070         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31071         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31072         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
31073         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
31074         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31075         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
31076         return (int64_t)ret_conv;
31077 }
31078
31079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1from_1hash(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
31080         LDKExpandedKey keys_conv;
31081         keys_conv.inner = (void*)(keys & (~1));
31082         keys_conv.is_owned = false;
31083         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31084         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31085         CHECK_ACCESS(min_value_msat_ptr);
31086         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31087         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31088         LDKThirtyTwoBytes payment_hash_ref;
31089         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31090         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31091         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31092         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
31093         return (int64_t)ret_conv;
31094 }
31095
31096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31097         LDKDecodeError this_obj_conv;
31098         this_obj_conv.inner = (void*)(this_obj & (~1));
31099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31101         DecodeError_free(this_obj_conv);
31102 }
31103
31104 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
31105         LDKDecodeError ret_var = DecodeError_clone(arg);
31106 int64_t ret_ref = 0;
31107 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31108 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31109 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31110 ret_ref = (uintptr_t)ret_var.inner;
31111 if (ret_var.is_owned) {
31112         ret_ref |= 1;
31113 }
31114         return ret_ref;
31115 }
31116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31117         LDKDecodeError arg_conv;
31118         arg_conv.inner = (void*)(arg & (~1));
31119         arg_conv.is_owned = false;
31120         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31121         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
31122         return ret_conv;
31123 }
31124
31125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31126         LDKDecodeError orig_conv;
31127         orig_conv.inner = (void*)(orig & (~1));
31128         orig_conv.is_owned = false;
31129         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31130         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
31131         int64_t ret_ref = 0;
31132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31135         ret_ref = (uintptr_t)ret_var.inner;
31136         if (ret_var.is_owned) {
31137                 ret_ref |= 1;
31138         }
31139         return ret_ref;
31140 }
31141
31142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31143         LDKInit this_obj_conv;
31144         this_obj_conv.inner = (void*)(this_obj & (~1));
31145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31147         Init_free(this_obj_conv);
31148 }
31149
31150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31151         LDKInit this_ptr_conv;
31152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31153         this_ptr_conv.is_owned = false;
31154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31155         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
31156         int64_t ret_ref = 0;
31157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31160         ret_ref = (uintptr_t)ret_var.inner;
31161         if (ret_var.is_owned) {
31162                 ret_ref |= 1;
31163         }
31164         return ret_ref;
31165 }
31166
31167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31168         LDKInit this_ptr_conv;
31169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31170         this_ptr_conv.is_owned = false;
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31172         LDKInitFeatures val_conv;
31173         val_conv.inner = (void*)(val & (~1));
31174         val_conv.is_owned = (val & 1) || (val == 0);
31175         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31176         val_conv = InitFeatures_clone(&val_conv);
31177         Init_set_features(&this_ptr_conv, val_conv);
31178 }
31179
31180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
31181         LDKInit this_ptr_conv;
31182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31183         this_ptr_conv.is_owned = false;
31184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31185         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
31186         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
31187         int64_t ret_ref = (uintptr_t)ret_copy;
31188         return ret_ref;
31189 }
31190
31191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31192         LDKInit this_ptr_conv;
31193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31194         this_ptr_conv.is_owned = false;
31195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31196         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31197         CHECK_ACCESS(val_ptr);
31198         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
31199         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
31200         Init_set_remote_network_address(&this_ptr_conv, val_conv);
31201 }
31202
31203 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) {
31204         LDKInitFeatures features_arg_conv;
31205         features_arg_conv.inner = (void*)(features_arg & (~1));
31206         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31207         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31208         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31209         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
31210         CHECK_ACCESS(remote_network_address_arg_ptr);
31211         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
31212         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
31213         int64_t ret_ref = 0;
31214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31217         ret_ref = (uintptr_t)ret_var.inner;
31218         if (ret_var.is_owned) {
31219                 ret_ref |= 1;
31220         }
31221         return ret_ref;
31222 }
31223
31224 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
31225         LDKInit ret_var = Init_clone(arg);
31226 int64_t ret_ref = 0;
31227 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31228 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31229 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31230 ret_ref = (uintptr_t)ret_var.inner;
31231 if (ret_var.is_owned) {
31232         ret_ref |= 1;
31233 }
31234         return ret_ref;
31235 }
31236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31237         LDKInit arg_conv;
31238         arg_conv.inner = (void*)(arg & (~1));
31239         arg_conv.is_owned = false;
31240         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31241         int64_t ret_conv = Init_clone_ptr(&arg_conv);
31242         return ret_conv;
31243 }
31244
31245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31246         LDKInit orig_conv;
31247         orig_conv.inner = (void*)(orig & (~1));
31248         orig_conv.is_owned = false;
31249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31250         LDKInit ret_var = Init_clone(&orig_conv);
31251         int64_t ret_ref = 0;
31252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31255         ret_ref = (uintptr_t)ret_var.inner;
31256         if (ret_var.is_owned) {
31257                 ret_ref |= 1;
31258         }
31259         return ret_ref;
31260 }
31261
31262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31263         LDKErrorMessage this_obj_conv;
31264         this_obj_conv.inner = (void*)(this_obj & (~1));
31265         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31267         ErrorMessage_free(this_obj_conv);
31268 }
31269
31270 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31271         LDKErrorMessage this_ptr_conv;
31272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31273         this_ptr_conv.is_owned = false;
31274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31275         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31276         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
31277         return ret_arr;
31278 }
31279
31280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31281         LDKErrorMessage this_ptr_conv;
31282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31283         this_ptr_conv.is_owned = false;
31284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31285         LDKThirtyTwoBytes val_ref;
31286         CHECK((*env)->GetArrayLength(env, val) == 32);
31287         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31288         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
31289 }
31290
31291 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31292         LDKErrorMessage this_ptr_conv;
31293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31294         this_ptr_conv.is_owned = false;
31295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31296         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
31297         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31298         Str_free(ret_str);
31299         return ret_conv;
31300 }
31301
31302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31303         LDKErrorMessage this_ptr_conv;
31304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31305         this_ptr_conv.is_owned = false;
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31307         LDKStr val_conv = java_to_owned_str(env, val);
31308         ErrorMessage_set_data(&this_ptr_conv, val_conv);
31309 }
31310
31311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
31312         LDKThirtyTwoBytes channel_id_arg_ref;
31313         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31314         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31315         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
31316         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
31317         int64_t ret_ref = 0;
31318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31321         ret_ref = (uintptr_t)ret_var.inner;
31322         if (ret_var.is_owned) {
31323                 ret_ref |= 1;
31324         }
31325         return ret_ref;
31326 }
31327
31328 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
31329         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
31330 int64_t ret_ref = 0;
31331 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31332 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31333 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31334 ret_ref = (uintptr_t)ret_var.inner;
31335 if (ret_var.is_owned) {
31336         ret_ref |= 1;
31337 }
31338         return ret_ref;
31339 }
31340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31341         LDKErrorMessage arg_conv;
31342         arg_conv.inner = (void*)(arg & (~1));
31343         arg_conv.is_owned = false;
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31345         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
31346         return ret_conv;
31347 }
31348
31349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31350         LDKErrorMessage orig_conv;
31351         orig_conv.inner = (void*)(orig & (~1));
31352         orig_conv.is_owned = false;
31353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31354         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
31355         int64_t ret_ref = 0;
31356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31359         ret_ref = (uintptr_t)ret_var.inner;
31360         if (ret_var.is_owned) {
31361                 ret_ref |= 1;
31362         }
31363         return ret_ref;
31364 }
31365
31366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31367         LDKWarningMessage this_obj_conv;
31368         this_obj_conv.inner = (void*)(this_obj & (~1));
31369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31371         WarningMessage_free(this_obj_conv);
31372 }
31373
31374 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31375         LDKWarningMessage this_ptr_conv;
31376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31377         this_ptr_conv.is_owned = false;
31378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31379         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31380         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
31381         return ret_arr;
31382 }
31383
31384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31385         LDKWarningMessage this_ptr_conv;
31386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31387         this_ptr_conv.is_owned = false;
31388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31389         LDKThirtyTwoBytes val_ref;
31390         CHECK((*env)->GetArrayLength(env, val) == 32);
31391         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31392         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
31393 }
31394
31395 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31396         LDKWarningMessage this_ptr_conv;
31397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31398         this_ptr_conv.is_owned = false;
31399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31400         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
31401         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31402         Str_free(ret_str);
31403         return ret_conv;
31404 }
31405
31406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31407         LDKWarningMessage this_ptr_conv;
31408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31409         this_ptr_conv.is_owned = false;
31410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31411         LDKStr val_conv = java_to_owned_str(env, val);
31412         WarningMessage_set_data(&this_ptr_conv, val_conv);
31413 }
31414
31415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
31416         LDKThirtyTwoBytes channel_id_arg_ref;
31417         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31418         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31419         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
31420         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
31421         int64_t ret_ref = 0;
31422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31425         ret_ref = (uintptr_t)ret_var.inner;
31426         if (ret_var.is_owned) {
31427                 ret_ref |= 1;
31428         }
31429         return ret_ref;
31430 }
31431
31432 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
31433         LDKWarningMessage ret_var = WarningMessage_clone(arg);
31434 int64_t ret_ref = 0;
31435 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31436 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31437 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31438 ret_ref = (uintptr_t)ret_var.inner;
31439 if (ret_var.is_owned) {
31440         ret_ref |= 1;
31441 }
31442         return ret_ref;
31443 }
31444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31445         LDKWarningMessage arg_conv;
31446         arg_conv.inner = (void*)(arg & (~1));
31447         arg_conv.is_owned = false;
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31449         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
31450         return ret_conv;
31451 }
31452
31453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31454         LDKWarningMessage orig_conv;
31455         orig_conv.inner = (void*)(orig & (~1));
31456         orig_conv.is_owned = false;
31457         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31458         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
31459         int64_t ret_ref = 0;
31460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31463         ret_ref = (uintptr_t)ret_var.inner;
31464         if (ret_var.is_owned) {
31465                 ret_ref |= 1;
31466         }
31467         return ret_ref;
31468 }
31469
31470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31471         LDKPing this_obj_conv;
31472         this_obj_conv.inner = (void*)(this_obj & (~1));
31473         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31475         Ping_free(this_obj_conv);
31476 }
31477
31478 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31479         LDKPing this_ptr_conv;
31480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31481         this_ptr_conv.is_owned = false;
31482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31483         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
31484         return ret_conv;
31485 }
31486
31487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31488         LDKPing 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         Ping_set_ponglen(&this_ptr_conv, val);
31493 }
31494
31495 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31496         LDKPing this_ptr_conv;
31497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31498         this_ptr_conv.is_owned = false;
31499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31500         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
31501         return ret_conv;
31502 }
31503
31504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31505         LDKPing this_ptr_conv;
31506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31507         this_ptr_conv.is_owned = false;
31508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31509         Ping_set_byteslen(&this_ptr_conv, val);
31510 }
31511
31512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
31513         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
31514         int64_t ret_ref = 0;
31515         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31516         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31518         ret_ref = (uintptr_t)ret_var.inner;
31519         if (ret_var.is_owned) {
31520                 ret_ref |= 1;
31521         }
31522         return ret_ref;
31523 }
31524
31525 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
31526         LDKPing ret_var = Ping_clone(arg);
31527 int64_t ret_ref = 0;
31528 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31529 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31530 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31531 ret_ref = (uintptr_t)ret_var.inner;
31532 if (ret_var.is_owned) {
31533         ret_ref |= 1;
31534 }
31535         return ret_ref;
31536 }
31537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31538         LDKPing arg_conv;
31539         arg_conv.inner = (void*)(arg & (~1));
31540         arg_conv.is_owned = false;
31541         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31542         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
31543         return ret_conv;
31544 }
31545
31546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31547         LDKPing orig_conv;
31548         orig_conv.inner = (void*)(orig & (~1));
31549         orig_conv.is_owned = false;
31550         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31551         LDKPing ret_var = Ping_clone(&orig_conv);
31552         int64_t ret_ref = 0;
31553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31556         ret_ref = (uintptr_t)ret_var.inner;
31557         if (ret_var.is_owned) {
31558                 ret_ref |= 1;
31559         }
31560         return ret_ref;
31561 }
31562
31563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31564         LDKPong this_obj_conv;
31565         this_obj_conv.inner = (void*)(this_obj & (~1));
31566         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31568         Pong_free(this_obj_conv);
31569 }
31570
31571 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31572         LDKPong this_ptr_conv;
31573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31574         this_ptr_conv.is_owned = false;
31575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31576         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
31577         return ret_conv;
31578 }
31579
31580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31581         LDKPong this_ptr_conv;
31582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31583         this_ptr_conv.is_owned = false;
31584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31585         Pong_set_byteslen(&this_ptr_conv, val);
31586 }
31587
31588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
31589         LDKPong ret_var = Pong_new(byteslen_arg);
31590         int64_t ret_ref = 0;
31591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31594         ret_ref = (uintptr_t)ret_var.inner;
31595         if (ret_var.is_owned) {
31596                 ret_ref |= 1;
31597         }
31598         return ret_ref;
31599 }
31600
31601 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
31602         LDKPong ret_var = Pong_clone(arg);
31603 int64_t ret_ref = 0;
31604 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31605 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31606 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31607 ret_ref = (uintptr_t)ret_var.inner;
31608 if (ret_var.is_owned) {
31609         ret_ref |= 1;
31610 }
31611         return ret_ref;
31612 }
31613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31614         LDKPong arg_conv;
31615         arg_conv.inner = (void*)(arg & (~1));
31616         arg_conv.is_owned = false;
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31618         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
31619         return ret_conv;
31620 }
31621
31622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31623         LDKPong orig_conv;
31624         orig_conv.inner = (void*)(orig & (~1));
31625         orig_conv.is_owned = false;
31626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31627         LDKPong ret_var = Pong_clone(&orig_conv);
31628         int64_t ret_ref = 0;
31629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31632         ret_ref = (uintptr_t)ret_var.inner;
31633         if (ret_var.is_owned) {
31634                 ret_ref |= 1;
31635         }
31636         return ret_ref;
31637 }
31638
31639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31640         LDKOpenChannel this_obj_conv;
31641         this_obj_conv.inner = (void*)(this_obj & (~1));
31642         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31644         OpenChannel_free(this_obj_conv);
31645 }
31646
31647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31648         LDKOpenChannel this_ptr_conv;
31649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31650         this_ptr_conv.is_owned = false;
31651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31652         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
31654         return ret_arr;
31655 }
31656
31657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31658         LDKOpenChannel this_ptr_conv;
31659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31660         this_ptr_conv.is_owned = false;
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31662         LDKThirtyTwoBytes val_ref;
31663         CHECK((*env)->GetArrayLength(env, val) == 32);
31664         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31665         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
31666 }
31667
31668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31669         LDKOpenChannel this_ptr_conv;
31670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31671         this_ptr_conv.is_owned = false;
31672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
31675         return ret_arr;
31676 }
31677
31678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31679         LDKOpenChannel this_ptr_conv;
31680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31681         this_ptr_conv.is_owned = false;
31682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31683         LDKThirtyTwoBytes val_ref;
31684         CHECK((*env)->GetArrayLength(env, val) == 32);
31685         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31686         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
31687 }
31688
31689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31690         LDKOpenChannel 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 = OpenChannel_get_funding_satoshis(&this_ptr_conv);
31695         return ret_conv;
31696 }
31697
31698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31699         LDKOpenChannel 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         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
31704 }
31705
31706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31707         LDKOpenChannel 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 = OpenChannel_get_push_msat(&this_ptr_conv);
31712         return ret_conv;
31713 }
31714
31715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31716         LDKOpenChannel 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         OpenChannel_set_push_msat(&this_ptr_conv, val);
31721 }
31722
31723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31724         LDKOpenChannel this_ptr_conv;
31725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31726         this_ptr_conv.is_owned = false;
31727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31728         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
31729         return ret_conv;
31730 }
31731
31732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31733         LDKOpenChannel this_ptr_conv;
31734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31735         this_ptr_conv.is_owned = false;
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31737         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
31738 }
31739
31740 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) {
31741         LDKOpenChannel this_ptr_conv;
31742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31743         this_ptr_conv.is_owned = false;
31744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31745         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
31746         return ret_conv;
31747 }
31748
31749 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) {
31750         LDKOpenChannel this_ptr_conv;
31751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31752         this_ptr_conv.is_owned = false;
31753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31754         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31755 }
31756
31757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31758         LDKOpenChannel this_ptr_conv;
31759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31760         this_ptr_conv.is_owned = false;
31761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31762         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
31763         return ret_conv;
31764 }
31765
31766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31767         LDKOpenChannel this_ptr_conv;
31768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31769         this_ptr_conv.is_owned = false;
31770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31771         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
31772 }
31773
31774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31775         LDKOpenChannel this_ptr_conv;
31776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31777         this_ptr_conv.is_owned = false;
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31779         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
31780         return ret_conv;
31781 }
31782
31783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31784         LDKOpenChannel this_ptr_conv;
31785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31786         this_ptr_conv.is_owned = false;
31787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31788         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
31789 }
31790
31791 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
31792         LDKOpenChannel this_ptr_conv;
31793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31794         this_ptr_conv.is_owned = false;
31795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31796         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
31797         return ret_conv;
31798 }
31799
31800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31801         LDKOpenChannel this_ptr_conv;
31802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31803         this_ptr_conv.is_owned = false;
31804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31805         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
31806 }
31807
31808 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31809         LDKOpenChannel this_ptr_conv;
31810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31811         this_ptr_conv.is_owned = false;
31812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31813         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
31814         return ret_conv;
31815 }
31816
31817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31818         LDKOpenChannel this_ptr_conv;
31819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31820         this_ptr_conv.is_owned = false;
31821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31822         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
31823 }
31824
31825 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31826         LDKOpenChannel this_ptr_conv;
31827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31828         this_ptr_conv.is_owned = false;
31829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31830         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
31831         return ret_conv;
31832 }
31833
31834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31835         LDKOpenChannel this_ptr_conv;
31836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31837         this_ptr_conv.is_owned = false;
31838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31839         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
31840 }
31841
31842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31843         LDKOpenChannel this_ptr_conv;
31844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31845         this_ptr_conv.is_owned = false;
31846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31847         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
31849         return ret_arr;
31850 }
31851
31852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31853         LDKOpenChannel this_ptr_conv;
31854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31855         this_ptr_conv.is_owned = false;
31856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31857         LDKPublicKey val_ref;
31858         CHECK((*env)->GetArrayLength(env, val) == 33);
31859         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31860         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31861 }
31862
31863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31864         LDKOpenChannel this_ptr_conv;
31865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31866         this_ptr_conv.is_owned = false;
31867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31868         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31869         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31870         return ret_arr;
31871 }
31872
31873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31874         LDKOpenChannel this_ptr_conv;
31875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31876         this_ptr_conv.is_owned = false;
31877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31878         LDKPublicKey val_ref;
31879         CHECK((*env)->GetArrayLength(env, val) == 33);
31880         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31881         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31882 }
31883
31884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31885         LDKOpenChannel this_ptr_conv;
31886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31887         this_ptr_conv.is_owned = false;
31888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31889         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
31891         return ret_arr;
31892 }
31893
31894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31895         LDKOpenChannel this_ptr_conv;
31896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31897         this_ptr_conv.is_owned = false;
31898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31899         LDKPublicKey val_ref;
31900         CHECK((*env)->GetArrayLength(env, val) == 33);
31901         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31902         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
31903 }
31904
31905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31906         LDKOpenChannel this_ptr_conv;
31907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31908         this_ptr_conv.is_owned = false;
31909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31910         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31912         return ret_arr;
31913 }
31914
31915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31916         LDKOpenChannel this_ptr_conv;
31917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31918         this_ptr_conv.is_owned = false;
31919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31920         LDKPublicKey val_ref;
31921         CHECK((*env)->GetArrayLength(env, val) == 33);
31922         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31923         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31924 }
31925
31926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31927         LDKOpenChannel this_ptr_conv;
31928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31929         this_ptr_conv.is_owned = false;
31930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31931         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31933         return ret_arr;
31934 }
31935
31936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31937         LDKOpenChannel this_ptr_conv;
31938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31939         this_ptr_conv.is_owned = false;
31940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31941         LDKPublicKey val_ref;
31942         CHECK((*env)->GetArrayLength(env, val) == 33);
31943         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31944         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31945 }
31946
31947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31948         LDKOpenChannel this_ptr_conv;
31949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31950         this_ptr_conv.is_owned = false;
31951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31952         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31953         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31954         return ret_arr;
31955 }
31956
31957 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) {
31958         LDKOpenChannel this_ptr_conv;
31959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31960         this_ptr_conv.is_owned = false;
31961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31962         LDKPublicKey val_ref;
31963         CHECK((*env)->GetArrayLength(env, val) == 33);
31964         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31965         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31966 }
31967
31968 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
31969         LDKOpenChannel this_ptr_conv;
31970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31971         this_ptr_conv.is_owned = false;
31972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31973         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
31974         return ret_conv;
31975 }
31976
31977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
31978         LDKOpenChannel this_ptr_conv;
31979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31980         this_ptr_conv.is_owned = false;
31981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31982         OpenChannel_set_channel_flags(&this_ptr_conv, val);
31983 }
31984
31985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31986         LDKOpenChannel this_ptr_conv;
31987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31988         this_ptr_conv.is_owned = false;
31989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31990         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
31991         int64_t ret_ref = 0;
31992         if ((uintptr_t)ret_var.inner > 4096) {
31993                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31994                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31996                 ret_ref = (uintptr_t)ret_var.inner;
31997                 if (ret_var.is_owned) {
31998                         ret_ref |= 1;
31999                 }
32000         }
32001         return ret_ref;
32002 }
32003
32004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32005         LDKOpenChannel this_ptr_conv;
32006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32007         this_ptr_conv.is_owned = false;
32008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32009         LDKChannelTypeFeatures val_conv;
32010         val_conv.inner = (void*)(val & (~1));
32011         val_conv.is_owned = (val & 1) || (val == 0);
32012         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32013         val_conv = ChannelTypeFeatures_clone(&val_conv);
32014         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
32015 }
32016
32017 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
32018         LDKOpenChannel ret_var = OpenChannel_clone(arg);
32019 int64_t ret_ref = 0;
32020 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32021 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32023 ret_ref = (uintptr_t)ret_var.inner;
32024 if (ret_var.is_owned) {
32025         ret_ref |= 1;
32026 }
32027         return ret_ref;
32028 }
32029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32030         LDKOpenChannel arg_conv;
32031         arg_conv.inner = (void*)(arg & (~1));
32032         arg_conv.is_owned = false;
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32034         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
32035         return ret_conv;
32036 }
32037
32038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32039         LDKOpenChannel orig_conv;
32040         orig_conv.inner = (void*)(orig & (~1));
32041         orig_conv.is_owned = false;
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32043         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
32044         int64_t ret_ref = 0;
32045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32048         ret_ref = (uintptr_t)ret_var.inner;
32049         if (ret_var.is_owned) {
32050                 ret_ref |= 1;
32051         }
32052         return ret_ref;
32053 }
32054
32055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32056         LDKAcceptChannel this_obj_conv;
32057         this_obj_conv.inner = (void*)(this_obj & (~1));
32058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32060         AcceptChannel_free(this_obj_conv);
32061 }
32062
32063 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32064         LDKAcceptChannel this_ptr_conv;
32065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32066         this_ptr_conv.is_owned = false;
32067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32068         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
32070         return ret_arr;
32071 }
32072
32073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32074         LDKAcceptChannel this_ptr_conv;
32075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32076         this_ptr_conv.is_owned = false;
32077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32078         LDKThirtyTwoBytes val_ref;
32079         CHECK((*env)->GetArrayLength(env, val) == 32);
32080         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32081         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32082 }
32083
32084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32085         LDKAcceptChannel this_ptr_conv;
32086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32087         this_ptr_conv.is_owned = false;
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32089         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
32090         return ret_conv;
32091 }
32092
32093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32094         LDKAcceptChannel this_ptr_conv;
32095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32096         this_ptr_conv.is_owned = false;
32097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32098         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32099 }
32100
32101 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) {
32102         LDKAcceptChannel this_ptr_conv;
32103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32104         this_ptr_conv.is_owned = false;
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32106         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32107         return ret_conv;
32108 }
32109
32110 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) {
32111         LDKAcceptChannel this_ptr_conv;
32112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32113         this_ptr_conv.is_owned = false;
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32115         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32116 }
32117
32118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32119         LDKAcceptChannel this_ptr_conv;
32120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32121         this_ptr_conv.is_owned = false;
32122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32123         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32124         return ret_conv;
32125 }
32126
32127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32128         LDKAcceptChannel this_ptr_conv;
32129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32130         this_ptr_conv.is_owned = false;
32131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32132         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32133 }
32134
32135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32136         LDKAcceptChannel this_ptr_conv;
32137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32138         this_ptr_conv.is_owned = false;
32139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32140         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
32141         return ret_conv;
32142 }
32143
32144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32145         LDKAcceptChannel this_ptr_conv;
32146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32147         this_ptr_conv.is_owned = false;
32148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32149         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32150 }
32151
32152 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
32153         LDKAcceptChannel this_ptr_conv;
32154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32155         this_ptr_conv.is_owned = false;
32156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32157         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
32158         return ret_conv;
32159 }
32160
32161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32162         LDKAcceptChannel this_ptr_conv;
32163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32164         this_ptr_conv.is_owned = false;
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32166         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
32167 }
32168
32169 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32170         LDKAcceptChannel this_ptr_conv;
32171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32172         this_ptr_conv.is_owned = false;
32173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32174         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
32175         return ret_conv;
32176 }
32177
32178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32179         LDKAcceptChannel this_ptr_conv;
32180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32181         this_ptr_conv.is_owned = false;
32182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32183         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
32184 }
32185
32186 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32187         LDKAcceptChannel this_ptr_conv;
32188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32189         this_ptr_conv.is_owned = false;
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32191         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
32192         return ret_conv;
32193 }
32194
32195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32196         LDKAcceptChannel this_ptr_conv;
32197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32198         this_ptr_conv.is_owned = false;
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32200         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32201 }
32202
32203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32204         LDKAcceptChannel this_ptr_conv;
32205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32206         this_ptr_conv.is_owned = false;
32207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32208         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32209         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32210         return ret_arr;
32211 }
32212
32213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32214         LDKAcceptChannel this_ptr_conv;
32215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32216         this_ptr_conv.is_owned = false;
32217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32218         LDKPublicKey val_ref;
32219         CHECK((*env)->GetArrayLength(env, val) == 33);
32220         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32221         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32222 }
32223
32224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32225         LDKAcceptChannel this_ptr_conv;
32226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32227         this_ptr_conv.is_owned = false;
32228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32229         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32230         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32231         return ret_arr;
32232 }
32233
32234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32235         LDKAcceptChannel this_ptr_conv;
32236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32237         this_ptr_conv.is_owned = false;
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32239         LDKPublicKey val_ref;
32240         CHECK((*env)->GetArrayLength(env, val) == 33);
32241         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32242         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32243 }
32244
32245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32246         LDKAcceptChannel this_ptr_conv;
32247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32248         this_ptr_conv.is_owned = false;
32249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32250         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
32252         return ret_arr;
32253 }
32254
32255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32256         LDKAcceptChannel this_ptr_conv;
32257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32258         this_ptr_conv.is_owned = false;
32259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32260         LDKPublicKey val_ref;
32261         CHECK((*env)->GetArrayLength(env, val) == 33);
32262         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32263         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
32264 }
32265
32266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32267         LDKAcceptChannel this_ptr_conv;
32268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32269         this_ptr_conv.is_owned = false;
32270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32271         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32273         return ret_arr;
32274 }
32275
32276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32277         LDKAcceptChannel this_ptr_conv;
32278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32279         this_ptr_conv.is_owned = false;
32280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32281         LDKPublicKey val_ref;
32282         CHECK((*env)->GetArrayLength(env, val) == 33);
32283         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32284         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32285 }
32286
32287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32288         LDKAcceptChannel this_ptr_conv;
32289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32290         this_ptr_conv.is_owned = false;
32291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32292         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32294         return ret_arr;
32295 }
32296
32297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32298         LDKAcceptChannel this_ptr_conv;
32299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32300         this_ptr_conv.is_owned = false;
32301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32302         LDKPublicKey val_ref;
32303         CHECK((*env)->GetArrayLength(env, val) == 33);
32304         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32305         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32306 }
32307
32308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32309         LDKAcceptChannel this_ptr_conv;
32310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32311         this_ptr_conv.is_owned = false;
32312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32313         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32314         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
32315         return ret_arr;
32316 }
32317
32318 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) {
32319         LDKAcceptChannel this_ptr_conv;
32320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32321         this_ptr_conv.is_owned = false;
32322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32323         LDKPublicKey val_ref;
32324         CHECK((*env)->GetArrayLength(env, val) == 33);
32325         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32326         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
32327 }
32328
32329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32330         LDKAcceptChannel this_ptr_conv;
32331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32332         this_ptr_conv.is_owned = false;
32333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32334         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
32335         int64_t ret_ref = 0;
32336         if ((uintptr_t)ret_var.inner > 4096) {
32337                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32338                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32340                 ret_ref = (uintptr_t)ret_var.inner;
32341                 if (ret_var.is_owned) {
32342                         ret_ref |= 1;
32343                 }
32344         }
32345         return ret_ref;
32346 }
32347
32348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32349         LDKAcceptChannel this_ptr_conv;
32350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32351         this_ptr_conv.is_owned = false;
32352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32353         LDKChannelTypeFeatures val_conv;
32354         val_conv.inner = (void*)(val & (~1));
32355         val_conv.is_owned = (val & 1) || (val == 0);
32356         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32357         val_conv = ChannelTypeFeatures_clone(&val_conv);
32358         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
32359 }
32360
32361 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
32362         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
32363 int64_t ret_ref = 0;
32364 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32365 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32366 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32367 ret_ref = (uintptr_t)ret_var.inner;
32368 if (ret_var.is_owned) {
32369         ret_ref |= 1;
32370 }
32371         return ret_ref;
32372 }
32373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32374         LDKAcceptChannel arg_conv;
32375         arg_conv.inner = (void*)(arg & (~1));
32376         arg_conv.is_owned = false;
32377         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32378         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
32379         return ret_conv;
32380 }
32381
32382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32383         LDKAcceptChannel orig_conv;
32384         orig_conv.inner = (void*)(orig & (~1));
32385         orig_conv.is_owned = false;
32386         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32387         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
32388         int64_t ret_ref = 0;
32389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32392         ret_ref = (uintptr_t)ret_var.inner;
32393         if (ret_var.is_owned) {
32394                 ret_ref |= 1;
32395         }
32396         return ret_ref;
32397 }
32398
32399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32400         LDKFundingCreated this_obj_conv;
32401         this_obj_conv.inner = (void*)(this_obj & (~1));
32402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32404         FundingCreated_free(this_obj_conv);
32405 }
32406
32407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32408         LDKFundingCreated this_ptr_conv;
32409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32410         this_ptr_conv.is_owned = false;
32411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32412         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
32414         return ret_arr;
32415 }
32416
32417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32418         LDKFundingCreated this_ptr_conv;
32419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32420         this_ptr_conv.is_owned = false;
32421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32422         LDKThirtyTwoBytes val_ref;
32423         CHECK((*env)->GetArrayLength(env, val) == 32);
32424         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32425         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
32426 }
32427
32428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
32429         LDKFundingCreated this_ptr_conv;
32430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32431         this_ptr_conv.is_owned = false;
32432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32433         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
32435         return ret_arr;
32436 }
32437
32438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32439         LDKFundingCreated this_ptr_conv;
32440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32441         this_ptr_conv.is_owned = false;
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         LDKThirtyTwoBytes val_ref;
32444         CHECK((*env)->GetArrayLength(env, val) == 32);
32445         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32446         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
32447 }
32448
32449 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
32450         LDKFundingCreated this_ptr_conv;
32451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32452         this_ptr_conv.is_owned = false;
32453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32454         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
32455         return ret_conv;
32456 }
32457
32458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32459         LDKFundingCreated this_ptr_conv;
32460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32461         this_ptr_conv.is_owned = false;
32462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32463         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
32464 }
32465
32466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32467         LDKFundingCreated this_ptr_conv;
32468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32469         this_ptr_conv.is_owned = false;
32470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32471         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
32473         return ret_arr;
32474 }
32475
32476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32477         LDKFundingCreated this_ptr_conv;
32478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32479         this_ptr_conv.is_owned = false;
32480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32481         LDKSignature val_ref;
32482         CHECK((*env)->GetArrayLength(env, val) == 64);
32483         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32484         FundingCreated_set_signature(&this_ptr_conv, val_ref);
32485 }
32486
32487 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) {
32488         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
32489         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
32490         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
32491         LDKThirtyTwoBytes funding_txid_arg_ref;
32492         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
32493         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
32494         LDKSignature signature_arg_ref;
32495         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32496         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32497         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
32498         int64_t ret_ref = 0;
32499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32502         ret_ref = (uintptr_t)ret_var.inner;
32503         if (ret_var.is_owned) {
32504                 ret_ref |= 1;
32505         }
32506         return ret_ref;
32507 }
32508
32509 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
32510         LDKFundingCreated ret_var = FundingCreated_clone(arg);
32511 int64_t ret_ref = 0;
32512 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32513 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32514 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32515 ret_ref = (uintptr_t)ret_var.inner;
32516 if (ret_var.is_owned) {
32517         ret_ref |= 1;
32518 }
32519         return ret_ref;
32520 }
32521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32522         LDKFundingCreated arg_conv;
32523         arg_conv.inner = (void*)(arg & (~1));
32524         arg_conv.is_owned = false;
32525         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32526         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
32527         return ret_conv;
32528 }
32529
32530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32531         LDKFundingCreated orig_conv;
32532         orig_conv.inner = (void*)(orig & (~1));
32533         orig_conv.is_owned = false;
32534         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32535         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
32536         int64_t ret_ref = 0;
32537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32540         ret_ref = (uintptr_t)ret_var.inner;
32541         if (ret_var.is_owned) {
32542                 ret_ref |= 1;
32543         }
32544         return ret_ref;
32545 }
32546
32547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32548         LDKFundingSigned this_obj_conv;
32549         this_obj_conv.inner = (void*)(this_obj & (~1));
32550         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32552         FundingSigned_free(this_obj_conv);
32553 }
32554
32555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32556         LDKFundingSigned this_ptr_conv;
32557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32558         this_ptr_conv.is_owned = false;
32559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32560         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
32562         return ret_arr;
32563 }
32564
32565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32566         LDKFundingSigned this_ptr_conv;
32567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32568         this_ptr_conv.is_owned = false;
32569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32570         LDKThirtyTwoBytes val_ref;
32571         CHECK((*env)->GetArrayLength(env, val) == 32);
32572         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32573         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
32574 }
32575
32576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32577         LDKFundingSigned this_ptr_conv;
32578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32579         this_ptr_conv.is_owned = false;
32580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32581         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32582         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
32583         return ret_arr;
32584 }
32585
32586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32587         LDKFundingSigned this_ptr_conv;
32588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32589         this_ptr_conv.is_owned = false;
32590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32591         LDKSignature val_ref;
32592         CHECK((*env)->GetArrayLength(env, val) == 64);
32593         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32594         FundingSigned_set_signature(&this_ptr_conv, val_ref);
32595 }
32596
32597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
32598         LDKThirtyTwoBytes channel_id_arg_ref;
32599         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32600         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32601         LDKSignature signature_arg_ref;
32602         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32603         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32604         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
32605         int64_t ret_ref = 0;
32606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32609         ret_ref = (uintptr_t)ret_var.inner;
32610         if (ret_var.is_owned) {
32611                 ret_ref |= 1;
32612         }
32613         return ret_ref;
32614 }
32615
32616 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
32617         LDKFundingSigned ret_var = FundingSigned_clone(arg);
32618 int64_t ret_ref = 0;
32619 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32620 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32621 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32622 ret_ref = (uintptr_t)ret_var.inner;
32623 if (ret_var.is_owned) {
32624         ret_ref |= 1;
32625 }
32626         return ret_ref;
32627 }
32628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32629         LDKFundingSigned arg_conv;
32630         arg_conv.inner = (void*)(arg & (~1));
32631         arg_conv.is_owned = false;
32632         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32633         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
32634         return ret_conv;
32635 }
32636
32637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32638         LDKFundingSigned orig_conv;
32639         orig_conv.inner = (void*)(orig & (~1));
32640         orig_conv.is_owned = false;
32641         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32642         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
32643         int64_t ret_ref = 0;
32644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32647         ret_ref = (uintptr_t)ret_var.inner;
32648         if (ret_var.is_owned) {
32649                 ret_ref |= 1;
32650         }
32651         return ret_ref;
32652 }
32653
32654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32655         LDKChannelReady this_obj_conv;
32656         this_obj_conv.inner = (void*)(this_obj & (~1));
32657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32659         ChannelReady_free(this_obj_conv);
32660 }
32661
32662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32663         LDKChannelReady this_ptr_conv;
32664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32665         this_ptr_conv.is_owned = false;
32666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32667         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32668         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
32669         return ret_arr;
32670 }
32671
32672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32673         LDKChannelReady this_ptr_conv;
32674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32675         this_ptr_conv.is_owned = false;
32676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32677         LDKThirtyTwoBytes val_ref;
32678         CHECK((*env)->GetArrayLength(env, val) == 32);
32679         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32680         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
32681 }
32682
32683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32684         LDKChannelReady this_ptr_conv;
32685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32686         this_ptr_conv.is_owned = false;
32687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32688         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32690         return ret_arr;
32691 }
32692
32693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32694         LDKChannelReady 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         LDKPublicKey val_ref;
32699         CHECK((*env)->GetArrayLength(env, val) == 33);
32700         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32701         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32702 }
32703
32704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32705         LDKChannelReady this_ptr_conv;
32706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32707         this_ptr_conv.is_owned = false;
32708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32709         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32710         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
32711         int64_t ret_ref = (uintptr_t)ret_copy;
32712         return ret_ref;
32713 }
32714
32715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32716         LDKChannelReady this_ptr_conv;
32717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32718         this_ptr_conv.is_owned = false;
32719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32720         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32721         CHECK_ACCESS(val_ptr);
32722         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32723         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32724         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
32725 }
32726
32727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
32728         LDKThirtyTwoBytes channel_id_arg_ref;
32729         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32730         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32731         LDKPublicKey next_per_commitment_point_arg_ref;
32732         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32733         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32734         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
32735         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
32736         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
32737         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
32738         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
32739         int64_t ret_ref = 0;
32740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32743         ret_ref = (uintptr_t)ret_var.inner;
32744         if (ret_var.is_owned) {
32745                 ret_ref |= 1;
32746         }
32747         return ret_ref;
32748 }
32749
32750 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
32751         LDKChannelReady ret_var = ChannelReady_clone(arg);
32752 int64_t ret_ref = 0;
32753 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32754 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32755 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32756 ret_ref = (uintptr_t)ret_var.inner;
32757 if (ret_var.is_owned) {
32758         ret_ref |= 1;
32759 }
32760         return ret_ref;
32761 }
32762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32763         LDKChannelReady arg_conv;
32764         arg_conv.inner = (void*)(arg & (~1));
32765         arg_conv.is_owned = false;
32766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32767         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
32768         return ret_conv;
32769 }
32770
32771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32772         LDKChannelReady orig_conv;
32773         orig_conv.inner = (void*)(orig & (~1));
32774         orig_conv.is_owned = false;
32775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32776         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
32777         int64_t ret_ref = 0;
32778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32781         ret_ref = (uintptr_t)ret_var.inner;
32782         if (ret_var.is_owned) {
32783                 ret_ref |= 1;
32784         }
32785         return ret_ref;
32786 }
32787
32788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32789         LDKShutdown this_obj_conv;
32790         this_obj_conv.inner = (void*)(this_obj & (~1));
32791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32793         Shutdown_free(this_obj_conv);
32794 }
32795
32796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32797         LDKShutdown this_ptr_conv;
32798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32799         this_ptr_conv.is_owned = false;
32800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32801         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
32803         return ret_arr;
32804 }
32805
32806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32807         LDKShutdown this_ptr_conv;
32808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32809         this_ptr_conv.is_owned = false;
32810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32811         LDKThirtyTwoBytes val_ref;
32812         CHECK((*env)->GetArrayLength(env, val) == 32);
32813         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32814         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
32815 }
32816
32817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32818         LDKShutdown this_ptr_conv;
32819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32820         this_ptr_conv.is_owned = false;
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32822         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
32823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32825         return ret_arr;
32826 }
32827
32828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32829         LDKShutdown this_ptr_conv;
32830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32831         this_ptr_conv.is_owned = false;
32832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32833         LDKCVec_u8Z val_ref;
32834         val_ref.datalen = (*env)->GetArrayLength(env, val);
32835         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32836         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
32837         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
32838 }
32839
32840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
32841         LDKThirtyTwoBytes channel_id_arg_ref;
32842         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32843         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32844         LDKCVec_u8Z scriptpubkey_arg_ref;
32845         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
32846         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32847         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
32848         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
32849         int64_t ret_ref = 0;
32850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32853         ret_ref = (uintptr_t)ret_var.inner;
32854         if (ret_var.is_owned) {
32855                 ret_ref |= 1;
32856         }
32857         return ret_ref;
32858 }
32859
32860 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
32861         LDKShutdown ret_var = Shutdown_clone(arg);
32862 int64_t ret_ref = 0;
32863 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32864 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32865 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32866 ret_ref = (uintptr_t)ret_var.inner;
32867 if (ret_var.is_owned) {
32868         ret_ref |= 1;
32869 }
32870         return ret_ref;
32871 }
32872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32873         LDKShutdown arg_conv;
32874         arg_conv.inner = (void*)(arg & (~1));
32875         arg_conv.is_owned = false;
32876         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32877         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
32878         return ret_conv;
32879 }
32880
32881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32882         LDKShutdown orig_conv;
32883         orig_conv.inner = (void*)(orig & (~1));
32884         orig_conv.is_owned = false;
32885         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32886         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
32887         int64_t ret_ref = 0;
32888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32891         ret_ref = (uintptr_t)ret_var.inner;
32892         if (ret_var.is_owned) {
32893                 ret_ref |= 1;
32894         }
32895         return ret_ref;
32896 }
32897
32898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32899         LDKClosingSignedFeeRange this_obj_conv;
32900         this_obj_conv.inner = (void*)(this_obj & (~1));
32901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32903         ClosingSignedFeeRange_free(this_obj_conv);
32904 }
32905
32906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32907         LDKClosingSignedFeeRange this_ptr_conv;
32908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32909         this_ptr_conv.is_owned = false;
32910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32911         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
32912         return ret_conv;
32913 }
32914
32915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32916         LDKClosingSignedFeeRange this_ptr_conv;
32917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32918         this_ptr_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32920         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
32921 }
32922
32923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32924         LDKClosingSignedFeeRange this_ptr_conv;
32925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32926         this_ptr_conv.is_owned = false;
32927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32928         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
32929         return ret_conv;
32930 }
32931
32932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32933         LDKClosingSignedFeeRange this_ptr_conv;
32934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32935         this_ptr_conv.is_owned = false;
32936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32937         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
32938 }
32939
32940 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) {
32941         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
32942         int64_t ret_ref = 0;
32943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32946         ret_ref = (uintptr_t)ret_var.inner;
32947         if (ret_var.is_owned) {
32948                 ret_ref |= 1;
32949         }
32950         return ret_ref;
32951 }
32952
32953 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
32954         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
32955 int64_t ret_ref = 0;
32956 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32957 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32958 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32959 ret_ref = (uintptr_t)ret_var.inner;
32960 if (ret_var.is_owned) {
32961         ret_ref |= 1;
32962 }
32963         return ret_ref;
32964 }
32965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32966         LDKClosingSignedFeeRange arg_conv;
32967         arg_conv.inner = (void*)(arg & (~1));
32968         arg_conv.is_owned = false;
32969         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32970         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
32971         return ret_conv;
32972 }
32973
32974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32975         LDKClosingSignedFeeRange orig_conv;
32976         orig_conv.inner = (void*)(orig & (~1));
32977         orig_conv.is_owned = false;
32978         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32979         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
32980         int64_t ret_ref = 0;
32981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32984         ret_ref = (uintptr_t)ret_var.inner;
32985         if (ret_var.is_owned) {
32986                 ret_ref |= 1;
32987         }
32988         return ret_ref;
32989 }
32990
32991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32992         LDKClosingSigned this_obj_conv;
32993         this_obj_conv.inner = (void*)(this_obj & (~1));
32994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32996         ClosingSigned_free(this_obj_conv);
32997 }
32998
32999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33000         LDKClosingSigned this_ptr_conv;
33001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33002         this_ptr_conv.is_owned = false;
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33004         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
33006         return ret_arr;
33007 }
33008
33009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33010         LDKClosingSigned 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         LDKThirtyTwoBytes val_ref;
33015         CHECK((*env)->GetArrayLength(env, val) == 32);
33016         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33017         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
33018 }
33019
33020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33021         LDKClosingSigned this_ptr_conv;
33022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33023         this_ptr_conv.is_owned = false;
33024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33025         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
33026         return ret_conv;
33027 }
33028
33029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33030         LDKClosingSigned this_ptr_conv;
33031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33032         this_ptr_conv.is_owned = false;
33033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33034         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
33035 }
33036
33037 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33038         LDKClosingSigned this_ptr_conv;
33039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33040         this_ptr_conv.is_owned = false;
33041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33042         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
33044         return ret_arr;
33045 }
33046
33047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33048         LDKClosingSigned this_ptr_conv;
33049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33050         this_ptr_conv.is_owned = false;
33051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33052         LDKSignature val_ref;
33053         CHECK((*env)->GetArrayLength(env, val) == 64);
33054         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33055         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
33056 }
33057
33058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
33059         LDKClosingSigned this_ptr_conv;
33060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33061         this_ptr_conv.is_owned = false;
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33063         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
33064         int64_t ret_ref = 0;
33065         if ((uintptr_t)ret_var.inner > 4096) {
33066                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33067                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33069                 ret_ref = (uintptr_t)ret_var.inner;
33070                 if (ret_var.is_owned) {
33071                         ret_ref |= 1;
33072                 }
33073         }
33074         return ret_ref;
33075 }
33076
33077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33078         LDKClosingSigned this_ptr_conv;
33079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33080         this_ptr_conv.is_owned = false;
33081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33082         LDKClosingSignedFeeRange val_conv;
33083         val_conv.inner = (void*)(val & (~1));
33084         val_conv.is_owned = (val & 1) || (val == 0);
33085         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33086         val_conv = ClosingSignedFeeRange_clone(&val_conv);
33087         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
33088 }
33089
33090 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) {
33091         LDKThirtyTwoBytes channel_id_arg_ref;
33092         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33093         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33094         LDKSignature signature_arg_ref;
33095         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33096         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33097         LDKClosingSignedFeeRange fee_range_arg_conv;
33098         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
33099         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
33100         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
33101         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
33102         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
33103         int64_t ret_ref = 0;
33104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33107         ret_ref = (uintptr_t)ret_var.inner;
33108         if (ret_var.is_owned) {
33109                 ret_ref |= 1;
33110         }
33111         return ret_ref;
33112 }
33113
33114 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
33115         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
33116 int64_t ret_ref = 0;
33117 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33118 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33119 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33120 ret_ref = (uintptr_t)ret_var.inner;
33121 if (ret_var.is_owned) {
33122         ret_ref |= 1;
33123 }
33124         return ret_ref;
33125 }
33126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33127         LDKClosingSigned arg_conv;
33128         arg_conv.inner = (void*)(arg & (~1));
33129         arg_conv.is_owned = false;
33130         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33131         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
33132         return ret_conv;
33133 }
33134
33135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33136         LDKClosingSigned orig_conv;
33137         orig_conv.inner = (void*)(orig & (~1));
33138         orig_conv.is_owned = false;
33139         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33140         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
33141         int64_t ret_ref = 0;
33142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33145         ret_ref = (uintptr_t)ret_var.inner;
33146         if (ret_var.is_owned) {
33147                 ret_ref |= 1;
33148         }
33149         return ret_ref;
33150 }
33151
33152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33153         LDKUpdateAddHTLC this_obj_conv;
33154         this_obj_conv.inner = (void*)(this_obj & (~1));
33155         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33157         UpdateAddHTLC_free(this_obj_conv);
33158 }
33159
33160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33161         LDKUpdateAddHTLC this_ptr_conv;
33162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33163         this_ptr_conv.is_owned = false;
33164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33165         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33166         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
33167         return ret_arr;
33168 }
33169
33170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33171         LDKUpdateAddHTLC this_ptr_conv;
33172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33173         this_ptr_conv.is_owned = false;
33174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33175         LDKThirtyTwoBytes val_ref;
33176         CHECK((*env)->GetArrayLength(env, val) == 32);
33177         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33178         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
33179 }
33180
33181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33182         LDKUpdateAddHTLC this_ptr_conv;
33183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33184         this_ptr_conv.is_owned = false;
33185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33186         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
33187         return ret_conv;
33188 }
33189
33190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33191         LDKUpdateAddHTLC this_ptr_conv;
33192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33193         this_ptr_conv.is_owned = false;
33194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33195         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
33196 }
33197
33198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33199         LDKUpdateAddHTLC this_ptr_conv;
33200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33201         this_ptr_conv.is_owned = false;
33202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33203         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
33204         return ret_conv;
33205 }
33206
33207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33208         LDKUpdateAddHTLC 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         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
33213 }
33214
33215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33216         LDKUpdateAddHTLC this_ptr_conv;
33217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33218         this_ptr_conv.is_owned = false;
33219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
33222         return ret_arr;
33223 }
33224
33225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33226         LDKUpdateAddHTLC this_ptr_conv;
33227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33228         this_ptr_conv.is_owned = false;
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33230         LDKThirtyTwoBytes val_ref;
33231         CHECK((*env)->GetArrayLength(env, val) == 32);
33232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33233         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
33234 }
33235
33236 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33237         LDKUpdateAddHTLC this_ptr_conv;
33238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33239         this_ptr_conv.is_owned = false;
33240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33241         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
33242         return ret_conv;
33243 }
33244
33245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33246         LDKUpdateAddHTLC this_ptr_conv;
33247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33248         this_ptr_conv.is_owned = false;
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33250         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
33251 }
33252
33253 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
33254         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
33255 int64_t ret_ref = 0;
33256 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33257 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33258 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33259 ret_ref = (uintptr_t)ret_var.inner;
33260 if (ret_var.is_owned) {
33261         ret_ref |= 1;
33262 }
33263         return ret_ref;
33264 }
33265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33266         LDKUpdateAddHTLC arg_conv;
33267         arg_conv.inner = (void*)(arg & (~1));
33268         arg_conv.is_owned = false;
33269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33270         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
33271         return ret_conv;
33272 }
33273
33274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33275         LDKUpdateAddHTLC orig_conv;
33276         orig_conv.inner = (void*)(orig & (~1));
33277         orig_conv.is_owned = false;
33278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33279         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
33280         int64_t ret_ref = 0;
33281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33284         ret_ref = (uintptr_t)ret_var.inner;
33285         if (ret_var.is_owned) {
33286                 ret_ref |= 1;
33287         }
33288         return ret_ref;
33289 }
33290
33291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33292         LDKUpdateFulfillHTLC this_obj_conv;
33293         this_obj_conv.inner = (void*)(this_obj & (~1));
33294         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33296         UpdateFulfillHTLC_free(this_obj_conv);
33297 }
33298
33299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33300         LDKUpdateFulfillHTLC this_ptr_conv;
33301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33302         this_ptr_conv.is_owned = false;
33303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33304         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33305         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
33306         return ret_arr;
33307 }
33308
33309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33310         LDKUpdateFulfillHTLC this_ptr_conv;
33311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33312         this_ptr_conv.is_owned = false;
33313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33314         LDKThirtyTwoBytes val_ref;
33315         CHECK((*env)->GetArrayLength(env, val) == 32);
33316         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33317         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
33318 }
33319
33320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33321         LDKUpdateFulfillHTLC this_ptr_conv;
33322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33323         this_ptr_conv.is_owned = false;
33324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33325         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
33326         return ret_conv;
33327 }
33328
33329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33330         LDKUpdateFulfillHTLC this_ptr_conv;
33331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33332         this_ptr_conv.is_owned = false;
33333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33334         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
33335 }
33336
33337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
33338         LDKUpdateFulfillHTLC this_ptr_conv;
33339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33340         this_ptr_conv.is_owned = false;
33341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33342         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
33344         return ret_arr;
33345 }
33346
33347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33348         LDKUpdateFulfillHTLC this_ptr_conv;
33349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33350         this_ptr_conv.is_owned = false;
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33352         LDKThirtyTwoBytes val_ref;
33353         CHECK((*env)->GetArrayLength(env, val) == 32);
33354         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33355         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
33356 }
33357
33358 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) {
33359         LDKThirtyTwoBytes channel_id_arg_ref;
33360         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33361         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33362         LDKThirtyTwoBytes payment_preimage_arg_ref;
33363         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
33364         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
33365         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
33366         int64_t ret_ref = 0;
33367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33370         ret_ref = (uintptr_t)ret_var.inner;
33371         if (ret_var.is_owned) {
33372                 ret_ref |= 1;
33373         }
33374         return ret_ref;
33375 }
33376
33377 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
33378         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
33379 int64_t ret_ref = 0;
33380 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33381 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33382 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33383 ret_ref = (uintptr_t)ret_var.inner;
33384 if (ret_var.is_owned) {
33385         ret_ref |= 1;
33386 }
33387         return ret_ref;
33388 }
33389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33390         LDKUpdateFulfillHTLC arg_conv;
33391         arg_conv.inner = (void*)(arg & (~1));
33392         arg_conv.is_owned = false;
33393         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33394         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
33395         return ret_conv;
33396 }
33397
33398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33399         LDKUpdateFulfillHTLC orig_conv;
33400         orig_conv.inner = (void*)(orig & (~1));
33401         orig_conv.is_owned = false;
33402         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33403         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
33404         int64_t ret_ref = 0;
33405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33408         ret_ref = (uintptr_t)ret_var.inner;
33409         if (ret_var.is_owned) {
33410                 ret_ref |= 1;
33411         }
33412         return ret_ref;
33413 }
33414
33415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33416         LDKUpdateFailHTLC this_obj_conv;
33417         this_obj_conv.inner = (void*)(this_obj & (~1));
33418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33420         UpdateFailHTLC_free(this_obj_conv);
33421 }
33422
33423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33424         LDKUpdateFailHTLC this_ptr_conv;
33425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33426         this_ptr_conv.is_owned = false;
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33428         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33429         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
33430         return ret_arr;
33431 }
33432
33433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33434         LDKUpdateFailHTLC this_ptr_conv;
33435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33436         this_ptr_conv.is_owned = false;
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33438         LDKThirtyTwoBytes val_ref;
33439         CHECK((*env)->GetArrayLength(env, val) == 32);
33440         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33441         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
33442 }
33443
33444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33445         LDKUpdateFailHTLC this_ptr_conv;
33446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33447         this_ptr_conv.is_owned = false;
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33449         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
33450         return ret_conv;
33451 }
33452
33453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33454         LDKUpdateFailHTLC this_ptr_conv;
33455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33456         this_ptr_conv.is_owned = false;
33457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33458         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
33459 }
33460
33461 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
33462         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
33463 int64_t ret_ref = 0;
33464 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33465 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33466 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33467 ret_ref = (uintptr_t)ret_var.inner;
33468 if (ret_var.is_owned) {
33469         ret_ref |= 1;
33470 }
33471         return ret_ref;
33472 }
33473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33474         LDKUpdateFailHTLC arg_conv;
33475         arg_conv.inner = (void*)(arg & (~1));
33476         arg_conv.is_owned = false;
33477         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33478         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
33479         return ret_conv;
33480 }
33481
33482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33483         LDKUpdateFailHTLC orig_conv;
33484         orig_conv.inner = (void*)(orig & (~1));
33485         orig_conv.is_owned = false;
33486         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33487         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
33488         int64_t ret_ref = 0;
33489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33492         ret_ref = (uintptr_t)ret_var.inner;
33493         if (ret_var.is_owned) {
33494                 ret_ref |= 1;
33495         }
33496         return ret_ref;
33497 }
33498
33499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33500         LDKUpdateFailMalformedHTLC this_obj_conv;
33501         this_obj_conv.inner = (void*)(this_obj & (~1));
33502         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33504         UpdateFailMalformedHTLC_free(this_obj_conv);
33505 }
33506
33507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33508         LDKUpdateFailMalformedHTLC this_ptr_conv;
33509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33510         this_ptr_conv.is_owned = false;
33511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33512         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
33514         return ret_arr;
33515 }
33516
33517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33518         LDKUpdateFailMalformedHTLC this_ptr_conv;
33519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33520         this_ptr_conv.is_owned = false;
33521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33522         LDKThirtyTwoBytes val_ref;
33523         CHECK((*env)->GetArrayLength(env, val) == 32);
33524         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33525         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
33526 }
33527
33528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33529         LDKUpdateFailMalformedHTLC this_ptr_conv;
33530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33531         this_ptr_conv.is_owned = false;
33532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33533         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
33534         return ret_conv;
33535 }
33536
33537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33538         LDKUpdateFailMalformedHTLC this_ptr_conv;
33539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33540         this_ptr_conv.is_owned = false;
33541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33542         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
33543 }
33544
33545 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
33546         LDKUpdateFailMalformedHTLC 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         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
33551         return ret_conv;
33552 }
33553
33554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33555         LDKUpdateFailMalformedHTLC this_ptr_conv;
33556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33557         this_ptr_conv.is_owned = false;
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33559         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
33560 }
33561
33562 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
33563         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
33564 int64_t ret_ref = 0;
33565 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33566 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33567 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33568 ret_ref = (uintptr_t)ret_var.inner;
33569 if (ret_var.is_owned) {
33570         ret_ref |= 1;
33571 }
33572         return ret_ref;
33573 }
33574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33575         LDKUpdateFailMalformedHTLC arg_conv;
33576         arg_conv.inner = (void*)(arg & (~1));
33577         arg_conv.is_owned = false;
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33579         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
33580         return ret_conv;
33581 }
33582
33583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33584         LDKUpdateFailMalformedHTLC orig_conv;
33585         orig_conv.inner = (void*)(orig & (~1));
33586         orig_conv.is_owned = false;
33587         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33588         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
33589         int64_t ret_ref = 0;
33590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33593         ret_ref = (uintptr_t)ret_var.inner;
33594         if (ret_var.is_owned) {
33595                 ret_ref |= 1;
33596         }
33597         return ret_ref;
33598 }
33599
33600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33601         LDKCommitmentSigned this_obj_conv;
33602         this_obj_conv.inner = (void*)(this_obj & (~1));
33603         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33605         CommitmentSigned_free(this_obj_conv);
33606 }
33607
33608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33609         LDKCommitmentSigned this_ptr_conv;
33610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33611         this_ptr_conv.is_owned = false;
33612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33613         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
33615         return ret_arr;
33616 }
33617
33618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33619         LDKCommitmentSigned this_ptr_conv;
33620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33621         this_ptr_conv.is_owned = false;
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33623         LDKThirtyTwoBytes val_ref;
33624         CHECK((*env)->GetArrayLength(env, val) == 32);
33625         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33626         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
33627 }
33628
33629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33630         LDKCommitmentSigned this_ptr_conv;
33631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33632         this_ptr_conv.is_owned = false;
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33634         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33635         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
33636         return ret_arr;
33637 }
33638
33639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33640         LDKCommitmentSigned this_ptr_conv;
33641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33642         this_ptr_conv.is_owned = false;
33643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33644         LDKSignature val_ref;
33645         CHECK((*env)->GetArrayLength(env, val) == 64);
33646         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33647         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
33648 }
33649
33650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
33651         LDKCommitmentSigned this_ptr_conv;
33652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33653         this_ptr_conv.is_owned = false;
33654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33655         LDKCVec_SignatureZ val_constr;
33656         val_constr.datalen = (*env)->GetArrayLength(env, val);
33657         if (val_constr.datalen > 0)
33658                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33659         else
33660                 val_constr.data = NULL;
33661         for (size_t i = 0; i < val_constr.datalen; i++) {
33662                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
33663                 LDKSignature val_conv_8_ref;
33664                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
33665                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
33666                 val_constr.data[i] = val_conv_8_ref;
33667         }
33668         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
33669 }
33670
33671 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) {
33672         LDKThirtyTwoBytes channel_id_arg_ref;
33673         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33674         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33675         LDKSignature signature_arg_ref;
33676         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33677         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33678         LDKCVec_SignatureZ htlc_signatures_arg_constr;
33679         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
33680         if (htlc_signatures_arg_constr.datalen > 0)
33681                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33682         else
33683                 htlc_signatures_arg_constr.data = NULL;
33684         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
33685                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
33686                 LDKSignature htlc_signatures_arg_conv_8_ref;
33687                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
33688                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
33689                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
33690         }
33691         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
33692         int64_t ret_ref = 0;
33693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33696         ret_ref = (uintptr_t)ret_var.inner;
33697         if (ret_var.is_owned) {
33698                 ret_ref |= 1;
33699         }
33700         return ret_ref;
33701 }
33702
33703 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
33704         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
33705 int64_t ret_ref = 0;
33706 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33707 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33708 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33709 ret_ref = (uintptr_t)ret_var.inner;
33710 if (ret_var.is_owned) {
33711         ret_ref |= 1;
33712 }
33713         return ret_ref;
33714 }
33715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33716         LDKCommitmentSigned arg_conv;
33717         arg_conv.inner = (void*)(arg & (~1));
33718         arg_conv.is_owned = false;
33719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33720         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
33721         return ret_conv;
33722 }
33723
33724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33725         LDKCommitmentSigned orig_conv;
33726         orig_conv.inner = (void*)(orig & (~1));
33727         orig_conv.is_owned = false;
33728         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33729         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
33730         int64_t ret_ref = 0;
33731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33734         ret_ref = (uintptr_t)ret_var.inner;
33735         if (ret_var.is_owned) {
33736                 ret_ref |= 1;
33737         }
33738         return ret_ref;
33739 }
33740
33741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33742         LDKRevokeAndACK this_obj_conv;
33743         this_obj_conv.inner = (void*)(this_obj & (~1));
33744         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33746         RevokeAndACK_free(this_obj_conv);
33747 }
33748
33749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33750         LDKRevokeAndACK this_ptr_conv;
33751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33752         this_ptr_conv.is_owned = false;
33753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33754         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
33756         return ret_arr;
33757 }
33758
33759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33760         LDKRevokeAndACK this_ptr_conv;
33761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33762         this_ptr_conv.is_owned = false;
33763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33764         LDKThirtyTwoBytes val_ref;
33765         CHECK((*env)->GetArrayLength(env, val) == 32);
33766         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33767         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
33768 }
33769
33770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33771         LDKRevokeAndACK this_ptr_conv;
33772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33773         this_ptr_conv.is_owned = false;
33774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33775         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
33777         return ret_arr;
33778 }
33779
33780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33781         LDKRevokeAndACK this_ptr_conv;
33782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33783         this_ptr_conv.is_owned = false;
33784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33785         LDKThirtyTwoBytes val_ref;
33786         CHECK((*env)->GetArrayLength(env, val) == 32);
33787         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33788         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
33789 }
33790
33791 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33792         LDKRevokeAndACK this_ptr_conv;
33793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33794         this_ptr_conv.is_owned = false;
33795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33796         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33798         return ret_arr;
33799 }
33800
33801 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) {
33802         LDKRevokeAndACK this_ptr_conv;
33803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33804         this_ptr_conv.is_owned = false;
33805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33806         LDKPublicKey val_ref;
33807         CHECK((*env)->GetArrayLength(env, val) == 33);
33808         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33809         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33810 }
33811
33812 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) {
33813         LDKThirtyTwoBytes channel_id_arg_ref;
33814         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33815         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33816         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
33817         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
33818         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
33819         LDKPublicKey next_per_commitment_point_arg_ref;
33820         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33821         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33822         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
33823         int64_t ret_ref = 0;
33824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33827         ret_ref = (uintptr_t)ret_var.inner;
33828         if (ret_var.is_owned) {
33829                 ret_ref |= 1;
33830         }
33831         return ret_ref;
33832 }
33833
33834 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
33835         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33847         LDKRevokeAndACK arg_conv;
33848         arg_conv.inner = (void*)(arg & (~1));
33849         arg_conv.is_owned = false;
33850         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33851         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
33852         return ret_conv;
33853 }
33854
33855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33856         LDKRevokeAndACK orig_conv;
33857         orig_conv.inner = (void*)(orig & (~1));
33858         orig_conv.is_owned = false;
33859         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33860         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
33861         int64_t ret_ref = 0;
33862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33865         ret_ref = (uintptr_t)ret_var.inner;
33866         if (ret_var.is_owned) {
33867                 ret_ref |= 1;
33868         }
33869         return ret_ref;
33870 }
33871
33872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33873         LDKUpdateFee this_obj_conv;
33874         this_obj_conv.inner = (void*)(this_obj & (~1));
33875         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33877         UpdateFee_free(this_obj_conv);
33878 }
33879
33880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33881         LDKUpdateFee this_ptr_conv;
33882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33883         this_ptr_conv.is_owned = false;
33884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33885         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
33887         return ret_arr;
33888 }
33889
33890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33891         LDKUpdateFee this_ptr_conv;
33892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33893         this_ptr_conv.is_owned = false;
33894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33895         LDKThirtyTwoBytes val_ref;
33896         CHECK((*env)->GetArrayLength(env, val) == 32);
33897         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33898         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
33899 }
33900
33901 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
33902         LDKUpdateFee this_ptr_conv;
33903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33904         this_ptr_conv.is_owned = false;
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33906         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
33907         return ret_conv;
33908 }
33909
33910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33911         LDKUpdateFee this_ptr_conv;
33912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33913         this_ptr_conv.is_owned = false;
33914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33915         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
33916 }
33917
33918 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) {
33919         LDKThirtyTwoBytes channel_id_arg_ref;
33920         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33921         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33922         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
33923         int64_t ret_ref = 0;
33924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33927         ret_ref = (uintptr_t)ret_var.inner;
33928         if (ret_var.is_owned) {
33929                 ret_ref |= 1;
33930         }
33931         return ret_ref;
33932 }
33933
33934 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
33935         LDKUpdateFee ret_var = UpdateFee_clone(arg);
33936 int64_t ret_ref = 0;
33937 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33938 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33939 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33940 ret_ref = (uintptr_t)ret_var.inner;
33941 if (ret_var.is_owned) {
33942         ret_ref |= 1;
33943 }
33944         return ret_ref;
33945 }
33946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33947         LDKUpdateFee arg_conv;
33948         arg_conv.inner = (void*)(arg & (~1));
33949         arg_conv.is_owned = false;
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33951         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
33952         return ret_conv;
33953 }
33954
33955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33956         LDKUpdateFee orig_conv;
33957         orig_conv.inner = (void*)(orig & (~1));
33958         orig_conv.is_owned = false;
33959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33960         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
33961         int64_t ret_ref = 0;
33962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33965         ret_ref = (uintptr_t)ret_var.inner;
33966         if (ret_var.is_owned) {
33967                 ret_ref |= 1;
33968         }
33969         return ret_ref;
33970 }
33971
33972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33973         LDKDataLossProtect this_obj_conv;
33974         this_obj_conv.inner = (void*)(this_obj & (~1));
33975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33977         DataLossProtect_free(this_obj_conv);
33978 }
33979
33980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33981         LDKDataLossProtect this_ptr_conv;
33982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33983         this_ptr_conv.is_owned = false;
33984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33985         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33986         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
33987         return ret_arr;
33988 }
33989
33990 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) {
33991         LDKDataLossProtect this_ptr_conv;
33992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33993         this_ptr_conv.is_owned = false;
33994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33995         LDKThirtyTwoBytes val_ref;
33996         CHECK((*env)->GetArrayLength(env, val) == 32);
33997         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33998         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
33999 }
34000
34001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34002         LDKDataLossProtect this_ptr_conv;
34003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34004         this_ptr_conv.is_owned = false;
34005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34006         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
34008         return ret_arr;
34009 }
34010
34011 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) {
34012         LDKDataLossProtect this_ptr_conv;
34013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34014         this_ptr_conv.is_owned = false;
34015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34016         LDKPublicKey val_ref;
34017         CHECK((*env)->GetArrayLength(env, val) == 33);
34018         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34019         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
34020 }
34021
34022 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) {
34023         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
34024         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
34025         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
34026         LDKPublicKey my_current_per_commitment_point_arg_ref;
34027         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
34028         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
34029         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
34030         int64_t ret_ref = 0;
34031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34034         ret_ref = (uintptr_t)ret_var.inner;
34035         if (ret_var.is_owned) {
34036                 ret_ref |= 1;
34037         }
34038         return ret_ref;
34039 }
34040
34041 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
34042         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
34043 int64_t ret_ref = 0;
34044 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34045 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34046 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34047 ret_ref = (uintptr_t)ret_var.inner;
34048 if (ret_var.is_owned) {
34049         ret_ref |= 1;
34050 }
34051         return ret_ref;
34052 }
34053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34054         LDKDataLossProtect arg_conv;
34055         arg_conv.inner = (void*)(arg & (~1));
34056         arg_conv.is_owned = false;
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34058         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
34059         return ret_conv;
34060 }
34061
34062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34063         LDKDataLossProtect orig_conv;
34064         orig_conv.inner = (void*)(orig & (~1));
34065         orig_conv.is_owned = false;
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34067         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
34068         int64_t ret_ref = 0;
34069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34072         ret_ref = (uintptr_t)ret_var.inner;
34073         if (ret_var.is_owned) {
34074                 ret_ref |= 1;
34075         }
34076         return ret_ref;
34077 }
34078
34079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34080         LDKChannelReestablish this_obj_conv;
34081         this_obj_conv.inner = (void*)(this_obj & (~1));
34082         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34084         ChannelReestablish_free(this_obj_conv);
34085 }
34086
34087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34088         LDKChannelReestablish this_ptr_conv;
34089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34090         this_ptr_conv.is_owned = false;
34091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34092         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34093         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
34094         return ret_arr;
34095 }
34096
34097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34098         LDKChannelReestablish this_ptr_conv;
34099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34100         this_ptr_conv.is_owned = false;
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34102         LDKThirtyTwoBytes val_ref;
34103         CHECK((*env)->GetArrayLength(env, val) == 32);
34104         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34105         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
34106 }
34107
34108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34109         LDKChannelReestablish this_ptr_conv;
34110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34111         this_ptr_conv.is_owned = false;
34112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34113         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
34114         return ret_conv;
34115 }
34116
34117 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) {
34118         LDKChannelReestablish 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         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
34123 }
34124
34125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34126         LDKChannelReestablish this_ptr_conv;
34127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34128         this_ptr_conv.is_owned = false;
34129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34130         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
34131         return ret_conv;
34132 }
34133
34134 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) {
34135         LDKChannelReestablish this_ptr_conv;
34136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34137         this_ptr_conv.is_owned = false;
34138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34139         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
34140 }
34141
34142 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
34143         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
34144 int64_t ret_ref = 0;
34145 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34146 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34147 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34148 ret_ref = (uintptr_t)ret_var.inner;
34149 if (ret_var.is_owned) {
34150         ret_ref |= 1;
34151 }
34152         return ret_ref;
34153 }
34154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34155         LDKChannelReestablish arg_conv;
34156         arg_conv.inner = (void*)(arg & (~1));
34157         arg_conv.is_owned = false;
34158         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34159         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
34160         return ret_conv;
34161 }
34162
34163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34164         LDKChannelReestablish orig_conv;
34165         orig_conv.inner = (void*)(orig & (~1));
34166         orig_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34168         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
34169         int64_t ret_ref = 0;
34170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34173         ret_ref = (uintptr_t)ret_var.inner;
34174         if (ret_var.is_owned) {
34175                 ret_ref |= 1;
34176         }
34177         return ret_ref;
34178 }
34179
34180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34181         LDKAnnouncementSignatures this_obj_conv;
34182         this_obj_conv.inner = (void*)(this_obj & (~1));
34183         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34185         AnnouncementSignatures_free(this_obj_conv);
34186 }
34187
34188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34189         LDKAnnouncementSignatures this_ptr_conv;
34190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34191         this_ptr_conv.is_owned = false;
34192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34193         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
34195         return ret_arr;
34196 }
34197
34198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34199         LDKAnnouncementSignatures this_ptr_conv;
34200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34201         this_ptr_conv.is_owned = false;
34202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34203         LDKThirtyTwoBytes val_ref;
34204         CHECK((*env)->GetArrayLength(env, val) == 32);
34205         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34206         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
34207 }
34208
34209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34210         LDKAnnouncementSignatures this_ptr_conv;
34211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34212         this_ptr_conv.is_owned = false;
34213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34214         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
34215         return ret_conv;
34216 }
34217
34218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34219         LDKAnnouncementSignatures 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         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
34224 }
34225
34226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34227         LDKAnnouncementSignatures this_ptr_conv;
34228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34229         this_ptr_conv.is_owned = false;
34230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34231         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34232         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
34233         return ret_arr;
34234 }
34235
34236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34237         LDKAnnouncementSignatures this_ptr_conv;
34238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34239         this_ptr_conv.is_owned = false;
34240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34241         LDKSignature val_ref;
34242         CHECK((*env)->GetArrayLength(env, val) == 64);
34243         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34244         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
34245 }
34246
34247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34248         LDKAnnouncementSignatures this_ptr_conv;
34249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34250         this_ptr_conv.is_owned = false;
34251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34252         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
34254         return ret_arr;
34255 }
34256
34257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34258         LDKAnnouncementSignatures this_ptr_conv;
34259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34260         this_ptr_conv.is_owned = false;
34261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34262         LDKSignature val_ref;
34263         CHECK((*env)->GetArrayLength(env, val) == 64);
34264         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34265         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
34266 }
34267
34268 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) {
34269         LDKThirtyTwoBytes channel_id_arg_ref;
34270         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34271         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34272         LDKSignature node_signature_arg_ref;
34273         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
34274         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
34275         LDKSignature bitcoin_signature_arg_ref;
34276         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
34277         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
34278         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
34279         int64_t ret_ref = 0;
34280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34283         ret_ref = (uintptr_t)ret_var.inner;
34284         if (ret_var.is_owned) {
34285                 ret_ref |= 1;
34286         }
34287         return ret_ref;
34288 }
34289
34290 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
34291         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
34292 int64_t ret_ref = 0;
34293 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34294 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34295 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34296 ret_ref = (uintptr_t)ret_var.inner;
34297 if (ret_var.is_owned) {
34298         ret_ref |= 1;
34299 }
34300         return ret_ref;
34301 }
34302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34303         LDKAnnouncementSignatures arg_conv;
34304         arg_conv.inner = (void*)(arg & (~1));
34305         arg_conv.is_owned = false;
34306         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34307         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
34308         return ret_conv;
34309 }
34310
34311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34312         LDKAnnouncementSignatures orig_conv;
34313         orig_conv.inner = (void*)(orig & (~1));
34314         orig_conv.is_owned = false;
34315         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34316         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
34317         int64_t ret_ref = 0;
34318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34321         ret_ref = (uintptr_t)ret_var.inner;
34322         if (ret_var.is_owned) {
34323                 ret_ref |= 1;
34324         }
34325         return ret_ref;
34326 }
34327
34328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34329         if ((this_ptr & 1) != 0) return;
34330         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34331         CHECK_ACCESS(this_ptr_ptr);
34332         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
34333         FREE((void*)this_ptr);
34334         NetAddress_free(this_ptr_conv);
34335 }
34336
34337 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
34338         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34339         *ret_copy = NetAddress_clone(arg);
34340 int64_t ret_ref = (uintptr_t)ret_copy;
34341         return ret_ref;
34342 }
34343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34344         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
34345         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
34346         return ret_conv;
34347 }
34348
34349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34350         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
34351         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34352         *ret_copy = NetAddress_clone(orig_conv);
34353         int64_t ret_ref = (uintptr_t)ret_copy;
34354         return ret_ref;
34355 }
34356
34357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
34358         LDKFourBytes addr_ref;
34359         CHECK((*env)->GetArrayLength(env, addr) == 4);
34360         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
34361         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34362         *ret_copy = NetAddress_ipv4(addr_ref, port);
34363         int64_t ret_ref = (uintptr_t)ret_copy;
34364         return ret_ref;
34365 }
34366
34367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
34368         LDKSixteenBytes addr_ref;
34369         CHECK((*env)->GetArrayLength(env, addr) == 16);
34370         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
34371         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34372         *ret_copy = NetAddress_ipv6(addr_ref, port);
34373         int64_t ret_ref = (uintptr_t)ret_copy;
34374         return ret_ref;
34375 }
34376
34377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
34378         LDKTwelveBytes a_ref;
34379         CHECK((*env)->GetArrayLength(env, a) == 12);
34380         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
34381         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34382         *ret_copy = NetAddress_onion_v2(a_ref);
34383         int64_t ret_ref = (uintptr_t)ret_copy;
34384         return ret_ref;
34385 }
34386
34387 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) {
34388         LDKThirtyTwoBytes ed25519_pubkey_ref;
34389         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
34390         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
34391         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34392         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
34393         int64_t ret_ref = (uintptr_t)ret_copy;
34394         return ret_ref;
34395 }
34396
34397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
34398         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
34399         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
34400         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34401         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34402         CVec_u8Z_free(ret_var);
34403         return ret_arr;
34404 }
34405
34406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34407         LDKu8slice ser_ref;
34408         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34409         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34410         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
34411         *ret_conv = NetAddress_read(ser_ref);
34412         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34413         return (int64_t)ret_conv;
34414 }
34415
34416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34417         LDKUnsignedNodeAnnouncement this_obj_conv;
34418         this_obj_conv.inner = (void*)(this_obj & (~1));
34419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34421         UnsignedNodeAnnouncement_free(this_obj_conv);
34422 }
34423
34424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34425         LDKUnsignedNodeAnnouncement this_ptr_conv;
34426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34427         this_ptr_conv.is_owned = false;
34428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34429         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
34430         int64_t ret_ref = 0;
34431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34434         ret_ref = (uintptr_t)ret_var.inner;
34435         if (ret_var.is_owned) {
34436                 ret_ref |= 1;
34437         }
34438         return ret_ref;
34439 }
34440
34441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34442         LDKUnsignedNodeAnnouncement this_ptr_conv;
34443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34444         this_ptr_conv.is_owned = false;
34445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34446         LDKNodeFeatures val_conv;
34447         val_conv.inner = (void*)(val & (~1));
34448         val_conv.is_owned = (val & 1) || (val == 0);
34449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34450         val_conv = NodeFeatures_clone(&val_conv);
34451         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
34452 }
34453
34454 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34455         LDKUnsignedNodeAnnouncement this_ptr_conv;
34456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34457         this_ptr_conv.is_owned = false;
34458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34459         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
34460         return ret_conv;
34461 }
34462
34463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34464         LDKUnsignedNodeAnnouncement this_ptr_conv;
34465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34466         this_ptr_conv.is_owned = false;
34467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34468         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
34469 }
34470
34471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34472         LDKUnsignedNodeAnnouncement this_ptr_conv;
34473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34474         this_ptr_conv.is_owned = false;
34475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34476         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
34478         return ret_arr;
34479 }
34480
34481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34482         LDKUnsignedNodeAnnouncement this_ptr_conv;
34483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34484         this_ptr_conv.is_owned = false;
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34486         LDKPublicKey val_ref;
34487         CHECK((*env)->GetArrayLength(env, val) == 33);
34488         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34489         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
34490 }
34491
34492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
34493         LDKUnsignedNodeAnnouncement this_ptr_conv;
34494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34495         this_ptr_conv.is_owned = false;
34496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34497         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
34498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
34499         return ret_arr;
34500 }
34501
34502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34503         LDKUnsignedNodeAnnouncement this_ptr_conv;
34504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34505         this_ptr_conv.is_owned = false;
34506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34507         LDKThreeBytes val_ref;
34508         CHECK((*env)->GetArrayLength(env, val) == 3);
34509         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
34510         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
34511 }
34512
34513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
34514         LDKUnsignedNodeAnnouncement this_ptr_conv;
34515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34516         this_ptr_conv.is_owned = false;
34517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34518         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
34520         return ret_arr;
34521 }
34522
34523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34524         LDKUnsignedNodeAnnouncement this_ptr_conv;
34525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34526         this_ptr_conv.is_owned = false;
34527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34528         LDKThirtyTwoBytes val_ref;
34529         CHECK((*env)->GetArrayLength(env, val) == 32);
34530         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34531         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
34532 }
34533
34534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34535         LDKUnsignedNodeAnnouncement this_ptr_conv;
34536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34537         this_ptr_conv.is_owned = false;
34538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34539         LDKCVec_NetAddressZ val_constr;
34540         val_constr.datalen = (*env)->GetArrayLength(env, val);
34541         if (val_constr.datalen > 0)
34542                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
34543         else
34544                 val_constr.data = NULL;
34545         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34546         for (size_t m = 0; m < val_constr.datalen; m++) {
34547                 int64_t val_conv_12 = val_vals[m];
34548                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
34549                 CHECK_ACCESS(val_conv_12_ptr);
34550                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
34551                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
34552                 val_constr.data[m] = val_conv_12_conv;
34553         }
34554         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34555         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
34556 }
34557
34558 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
34559         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
34560 int64_t ret_ref = 0;
34561 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34562 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34564 ret_ref = (uintptr_t)ret_var.inner;
34565 if (ret_var.is_owned) {
34566         ret_ref |= 1;
34567 }
34568         return ret_ref;
34569 }
34570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34571         LDKUnsignedNodeAnnouncement arg_conv;
34572         arg_conv.inner = (void*)(arg & (~1));
34573         arg_conv.is_owned = false;
34574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34575         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
34576         return ret_conv;
34577 }
34578
34579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34580         LDKUnsignedNodeAnnouncement orig_conv;
34581         orig_conv.inner = (void*)(orig & (~1));
34582         orig_conv.is_owned = false;
34583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34584         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
34585         int64_t ret_ref = 0;
34586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34589         ret_ref = (uintptr_t)ret_var.inner;
34590         if (ret_var.is_owned) {
34591                 ret_ref |= 1;
34592         }
34593         return ret_ref;
34594 }
34595
34596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34597         LDKNodeAnnouncement this_obj_conv;
34598         this_obj_conv.inner = (void*)(this_obj & (~1));
34599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34601         NodeAnnouncement_free(this_obj_conv);
34602 }
34603
34604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34605         LDKNodeAnnouncement this_ptr_conv;
34606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34607         this_ptr_conv.is_owned = false;
34608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34609         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34610         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
34611         return ret_arr;
34612 }
34613
34614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34615         LDKNodeAnnouncement this_ptr_conv;
34616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34617         this_ptr_conv.is_owned = false;
34618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34619         LDKSignature val_ref;
34620         CHECK((*env)->GetArrayLength(env, val) == 64);
34621         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34622         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
34623 }
34624
34625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34626         LDKNodeAnnouncement 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         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
34631         int64_t ret_ref = 0;
34632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34635         ret_ref = (uintptr_t)ret_var.inner;
34636         if (ret_var.is_owned) {
34637                 ret_ref |= 1;
34638         }
34639         return ret_ref;
34640 }
34641
34642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34643         LDKNodeAnnouncement this_ptr_conv;
34644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34645         this_ptr_conv.is_owned = false;
34646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34647         LDKUnsignedNodeAnnouncement val_conv;
34648         val_conv.inner = (void*)(val & (~1));
34649         val_conv.is_owned = (val & 1) || (val == 0);
34650         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34651         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
34652         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
34653 }
34654
34655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34656         LDKSignature signature_arg_ref;
34657         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34658         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34659         LDKUnsignedNodeAnnouncement contents_arg_conv;
34660         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34661         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34663         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
34664         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
34665         int64_t ret_ref = 0;
34666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34669         ret_ref = (uintptr_t)ret_var.inner;
34670         if (ret_var.is_owned) {
34671                 ret_ref |= 1;
34672         }
34673         return ret_ref;
34674 }
34675
34676 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
34677         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
34678 int64_t ret_ref = 0;
34679 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34680 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34681 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34682 ret_ref = (uintptr_t)ret_var.inner;
34683 if (ret_var.is_owned) {
34684         ret_ref |= 1;
34685 }
34686         return ret_ref;
34687 }
34688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34689         LDKNodeAnnouncement arg_conv;
34690         arg_conv.inner = (void*)(arg & (~1));
34691         arg_conv.is_owned = false;
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34693         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
34694         return ret_conv;
34695 }
34696
34697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34698         LDKNodeAnnouncement orig_conv;
34699         orig_conv.inner = (void*)(orig & (~1));
34700         orig_conv.is_owned = false;
34701         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34702         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
34703         int64_t ret_ref = 0;
34704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34707         ret_ref = (uintptr_t)ret_var.inner;
34708         if (ret_var.is_owned) {
34709                 ret_ref |= 1;
34710         }
34711         return ret_ref;
34712 }
34713
34714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34715         LDKUnsignedChannelAnnouncement this_obj_conv;
34716         this_obj_conv.inner = (void*)(this_obj & (~1));
34717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34719         UnsignedChannelAnnouncement_free(this_obj_conv);
34720 }
34721
34722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34723         LDKUnsignedChannelAnnouncement this_ptr_conv;
34724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34725         this_ptr_conv.is_owned = false;
34726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34727         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
34728         int64_t ret_ref = 0;
34729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34732         ret_ref = (uintptr_t)ret_var.inner;
34733         if (ret_var.is_owned) {
34734                 ret_ref |= 1;
34735         }
34736         return ret_ref;
34737 }
34738
34739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34740         LDKUnsignedChannelAnnouncement this_ptr_conv;
34741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34742         this_ptr_conv.is_owned = false;
34743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34744         LDKChannelFeatures val_conv;
34745         val_conv.inner = (void*)(val & (~1));
34746         val_conv.is_owned = (val & 1) || (val == 0);
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34748         val_conv = ChannelFeatures_clone(&val_conv);
34749         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
34750 }
34751
34752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34753         LDKUnsignedChannelAnnouncement this_ptr_conv;
34754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34755         this_ptr_conv.is_owned = false;
34756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34757         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34758         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
34759         return ret_arr;
34760 }
34761
34762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34763         LDKUnsignedChannelAnnouncement this_ptr_conv;
34764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34765         this_ptr_conv.is_owned = false;
34766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34767         LDKThirtyTwoBytes val_ref;
34768         CHECK((*env)->GetArrayLength(env, val) == 32);
34769         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34770         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
34771 }
34772
34773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34774         LDKUnsignedChannelAnnouncement this_ptr_conv;
34775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34776         this_ptr_conv.is_owned = false;
34777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34778         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
34779         return ret_conv;
34780 }
34781
34782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34783         LDKUnsignedChannelAnnouncement this_ptr_conv;
34784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34785         this_ptr_conv.is_owned = false;
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34787         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
34788 }
34789
34790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34791         LDKUnsignedChannelAnnouncement this_ptr_conv;
34792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34793         this_ptr_conv.is_owned = false;
34794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34795         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34796         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
34797         return ret_arr;
34798 }
34799
34800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34801         LDKUnsignedChannelAnnouncement this_ptr_conv;
34802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34803         this_ptr_conv.is_owned = false;
34804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34805         LDKPublicKey val_ref;
34806         CHECK((*env)->GetArrayLength(env, val) == 33);
34807         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34808         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
34809 }
34810
34811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34812         LDKUnsignedChannelAnnouncement this_ptr_conv;
34813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34814         this_ptr_conv.is_owned = false;
34815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34816         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
34818         return ret_arr;
34819 }
34820
34821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34822         LDKUnsignedChannelAnnouncement this_ptr_conv;
34823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34824         this_ptr_conv.is_owned = false;
34825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34826         LDKPublicKey val_ref;
34827         CHECK((*env)->GetArrayLength(env, val) == 33);
34828         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34829         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
34830 }
34831
34832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34833         LDKUnsignedChannelAnnouncement this_ptr_conv;
34834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34835         this_ptr_conv.is_owned = false;
34836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34837         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
34839         return ret_arr;
34840 }
34841
34842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34843         LDKUnsignedChannelAnnouncement this_ptr_conv;
34844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34845         this_ptr_conv.is_owned = false;
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34847         LDKPublicKey val_ref;
34848         CHECK((*env)->GetArrayLength(env, val) == 33);
34849         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34850         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
34851 }
34852
34853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34854         LDKUnsignedChannelAnnouncement this_ptr_conv;
34855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34856         this_ptr_conv.is_owned = false;
34857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34858         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
34860         return ret_arr;
34861 }
34862
34863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34864         LDKUnsignedChannelAnnouncement this_ptr_conv;
34865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34866         this_ptr_conv.is_owned = false;
34867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34868         LDKPublicKey val_ref;
34869         CHECK((*env)->GetArrayLength(env, val) == 33);
34870         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34871         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
34872 }
34873
34874 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
34875         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
34876 int64_t ret_ref = 0;
34877 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34878 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34879 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34880 ret_ref = (uintptr_t)ret_var.inner;
34881 if (ret_var.is_owned) {
34882         ret_ref |= 1;
34883 }
34884         return ret_ref;
34885 }
34886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34887         LDKUnsignedChannelAnnouncement arg_conv;
34888         arg_conv.inner = (void*)(arg & (~1));
34889         arg_conv.is_owned = false;
34890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34891         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
34892         return ret_conv;
34893 }
34894
34895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34896         LDKUnsignedChannelAnnouncement orig_conv;
34897         orig_conv.inner = (void*)(orig & (~1));
34898         orig_conv.is_owned = false;
34899         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34900         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
34901         int64_t ret_ref = 0;
34902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34905         ret_ref = (uintptr_t)ret_var.inner;
34906         if (ret_var.is_owned) {
34907                 ret_ref |= 1;
34908         }
34909         return ret_ref;
34910 }
34911
34912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34913         LDKChannelAnnouncement this_obj_conv;
34914         this_obj_conv.inner = (void*)(this_obj & (~1));
34915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34917         ChannelAnnouncement_free(this_obj_conv);
34918 }
34919
34920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34921         LDKChannelAnnouncement 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34926         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
34927         return ret_arr;
34928 }
34929
34930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34931         LDKChannelAnnouncement this_ptr_conv;
34932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34933         this_ptr_conv.is_owned = false;
34934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34935         LDKSignature val_ref;
34936         CHECK((*env)->GetArrayLength(env, val) == 64);
34937         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34938         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
34939 }
34940
34941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34942         LDKChannelAnnouncement this_ptr_conv;
34943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34944         this_ptr_conv.is_owned = false;
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34946         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
34948         return ret_arr;
34949 }
34950
34951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34952         LDKChannelAnnouncement this_ptr_conv;
34953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34954         this_ptr_conv.is_owned = false;
34955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34956         LDKSignature val_ref;
34957         CHECK((*env)->GetArrayLength(env, val) == 64);
34958         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34959         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
34960 }
34961
34962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34963         LDKChannelAnnouncement this_ptr_conv;
34964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34965         this_ptr_conv.is_owned = false;
34966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34967         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
34969         return ret_arr;
34970 }
34971
34972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34973         LDKChannelAnnouncement this_ptr_conv;
34974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34975         this_ptr_conv.is_owned = false;
34976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34977         LDKSignature val_ref;
34978         CHECK((*env)->GetArrayLength(env, val) == 64);
34979         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34980         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
34981 }
34982
34983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34984         LDKChannelAnnouncement this_ptr_conv;
34985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34986         this_ptr_conv.is_owned = false;
34987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34988         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34989         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
34990         return ret_arr;
34991 }
34992
34993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34994         LDKChannelAnnouncement this_ptr_conv;
34995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34996         this_ptr_conv.is_owned = false;
34997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34998         LDKSignature val_ref;
34999         CHECK((*env)->GetArrayLength(env, val) == 64);
35000         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35001         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
35002 }
35003
35004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35005         LDKChannelAnnouncement this_ptr_conv;
35006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35007         this_ptr_conv.is_owned = false;
35008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35009         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
35010         int64_t ret_ref = 0;
35011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35014         ret_ref = (uintptr_t)ret_var.inner;
35015         if (ret_var.is_owned) {
35016                 ret_ref |= 1;
35017         }
35018         return ret_ref;
35019 }
35020
35021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35022         LDKChannelAnnouncement this_ptr_conv;
35023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35024         this_ptr_conv.is_owned = false;
35025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35026         LDKUnsignedChannelAnnouncement val_conv;
35027         val_conv.inner = (void*)(val & (~1));
35028         val_conv.is_owned = (val & 1) || (val == 0);
35029         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35030         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
35031         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
35032 }
35033
35034 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) {
35035         LDKSignature node_signature_1_arg_ref;
35036         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
35037         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
35038         LDKSignature node_signature_2_arg_ref;
35039         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
35040         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
35041         LDKSignature bitcoin_signature_1_arg_ref;
35042         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
35043         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
35044         LDKSignature bitcoin_signature_2_arg_ref;
35045         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
35046         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
35047         LDKUnsignedChannelAnnouncement contents_arg_conv;
35048         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35049         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35050         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35051         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
35052         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);
35053         int64_t ret_ref = 0;
35054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35057         ret_ref = (uintptr_t)ret_var.inner;
35058         if (ret_var.is_owned) {
35059                 ret_ref |= 1;
35060         }
35061         return ret_ref;
35062 }
35063
35064 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
35065         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
35066 int64_t ret_ref = 0;
35067 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35068 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35069 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35070 ret_ref = (uintptr_t)ret_var.inner;
35071 if (ret_var.is_owned) {
35072         ret_ref |= 1;
35073 }
35074         return ret_ref;
35075 }
35076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35077         LDKChannelAnnouncement arg_conv;
35078         arg_conv.inner = (void*)(arg & (~1));
35079         arg_conv.is_owned = false;
35080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35081         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
35082         return ret_conv;
35083 }
35084
35085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35086         LDKChannelAnnouncement orig_conv;
35087         orig_conv.inner = (void*)(orig & (~1));
35088         orig_conv.is_owned = false;
35089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35090         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
35091         int64_t ret_ref = 0;
35092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35095         ret_ref = (uintptr_t)ret_var.inner;
35096         if (ret_var.is_owned) {
35097                 ret_ref |= 1;
35098         }
35099         return ret_ref;
35100 }
35101
35102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35103         LDKUnsignedChannelUpdate this_obj_conv;
35104         this_obj_conv.inner = (void*)(this_obj & (~1));
35105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35107         UnsignedChannelUpdate_free(this_obj_conv);
35108 }
35109
35110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35111         LDKUnsignedChannelUpdate this_ptr_conv;
35112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35113         this_ptr_conv.is_owned = false;
35114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
35117         return ret_arr;
35118 }
35119
35120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35121         LDKUnsignedChannelUpdate this_ptr_conv;
35122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35123         this_ptr_conv.is_owned = false;
35124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35125         LDKThirtyTwoBytes val_ref;
35126         CHECK((*env)->GetArrayLength(env, val) == 32);
35127         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35128         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
35129 }
35130
35131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35132         LDKUnsignedChannelUpdate this_ptr_conv;
35133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35134         this_ptr_conv.is_owned = false;
35135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35136         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
35137         return ret_conv;
35138 }
35139
35140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35141         LDKUnsignedChannelUpdate this_ptr_conv;
35142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35143         this_ptr_conv.is_owned = false;
35144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35145         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
35146 }
35147
35148 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35149         LDKUnsignedChannelUpdate this_ptr_conv;
35150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35151         this_ptr_conv.is_owned = false;
35152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35153         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
35154         return ret_conv;
35155 }
35156
35157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35158         LDKUnsignedChannelUpdate this_ptr_conv;
35159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35160         this_ptr_conv.is_owned = false;
35161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35162         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
35163 }
35164
35165 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35166         LDKUnsignedChannelUpdate this_ptr_conv;
35167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35168         this_ptr_conv.is_owned = false;
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35170         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
35171         return ret_conv;
35172 }
35173
35174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35175         LDKUnsignedChannelUpdate this_ptr_conv;
35176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35177         this_ptr_conv.is_owned = false;
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35179         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
35180 }
35181
35182 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35183         LDKUnsignedChannelUpdate this_ptr_conv;
35184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35185         this_ptr_conv.is_owned = false;
35186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35187         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
35188         return ret_conv;
35189 }
35190
35191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35192         LDKUnsignedChannelUpdate this_ptr_conv;
35193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35194         this_ptr_conv.is_owned = false;
35195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35196         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
35197 }
35198
35199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35200         LDKUnsignedChannelUpdate this_ptr_conv;
35201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35202         this_ptr_conv.is_owned = false;
35203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35204         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
35205         return ret_conv;
35206 }
35207
35208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35209         LDKUnsignedChannelUpdate this_ptr_conv;
35210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35211         this_ptr_conv.is_owned = false;
35212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35213         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
35214 }
35215
35216 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35217         LDKUnsignedChannelUpdate this_ptr_conv;
35218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35219         this_ptr_conv.is_owned = false;
35220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35221         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
35222         return ret_conv;
35223 }
35224
35225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35226         LDKUnsignedChannelUpdate this_ptr_conv;
35227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35228         this_ptr_conv.is_owned = false;
35229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35230         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
35231 }
35232
35233 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
35234         LDKUnsignedChannelUpdate this_ptr_conv;
35235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35236         this_ptr_conv.is_owned = false;
35237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35238         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
35239         return ret_conv;
35240 }
35241
35242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35243         LDKUnsignedChannelUpdate this_ptr_conv;
35244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35245         this_ptr_conv.is_owned = false;
35246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35247         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
35248 }
35249
35250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35251         LDKUnsignedChannelUpdate this_ptr_conv;
35252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35253         this_ptr_conv.is_owned = false;
35254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35255         LDKCVec_u8Z val_ref;
35256         val_ref.datalen = (*env)->GetArrayLength(env, val);
35257         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35258         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35259         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
35260 }
35261
35262 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
35263         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
35264 int64_t ret_ref = 0;
35265 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35266 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35267 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35268 ret_ref = (uintptr_t)ret_var.inner;
35269 if (ret_var.is_owned) {
35270         ret_ref |= 1;
35271 }
35272         return ret_ref;
35273 }
35274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35275         LDKUnsignedChannelUpdate arg_conv;
35276         arg_conv.inner = (void*)(arg & (~1));
35277         arg_conv.is_owned = false;
35278         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35279         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
35280         return ret_conv;
35281 }
35282
35283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35284         LDKUnsignedChannelUpdate orig_conv;
35285         orig_conv.inner = (void*)(orig & (~1));
35286         orig_conv.is_owned = false;
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35288         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
35289         int64_t ret_ref = 0;
35290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35293         ret_ref = (uintptr_t)ret_var.inner;
35294         if (ret_var.is_owned) {
35295                 ret_ref |= 1;
35296         }
35297         return ret_ref;
35298 }
35299
35300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35301         LDKChannelUpdate this_obj_conv;
35302         this_obj_conv.inner = (void*)(this_obj & (~1));
35303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35305         ChannelUpdate_free(this_obj_conv);
35306 }
35307
35308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35309         LDKChannelUpdate this_ptr_conv;
35310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35311         this_ptr_conv.is_owned = false;
35312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35313         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35314         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
35315         return ret_arr;
35316 }
35317
35318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35319         LDKChannelUpdate this_ptr_conv;
35320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35321         this_ptr_conv.is_owned = false;
35322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35323         LDKSignature val_ref;
35324         CHECK((*env)->GetArrayLength(env, val) == 64);
35325         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35326         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
35327 }
35328
35329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35330         LDKChannelUpdate this_ptr_conv;
35331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35332         this_ptr_conv.is_owned = false;
35333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35334         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
35335         int64_t ret_ref = 0;
35336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35339         ret_ref = (uintptr_t)ret_var.inner;
35340         if (ret_var.is_owned) {
35341                 ret_ref |= 1;
35342         }
35343         return ret_ref;
35344 }
35345
35346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35347         LDKChannelUpdate this_ptr_conv;
35348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35349         this_ptr_conv.is_owned = false;
35350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35351         LDKUnsignedChannelUpdate val_conv;
35352         val_conv.inner = (void*)(val & (~1));
35353         val_conv.is_owned = (val & 1) || (val == 0);
35354         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35355         val_conv = UnsignedChannelUpdate_clone(&val_conv);
35356         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
35357 }
35358
35359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35360         LDKSignature signature_arg_ref;
35361         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35362         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35363         LDKUnsignedChannelUpdate contents_arg_conv;
35364         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35365         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35366         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35367         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
35368         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
35369         int64_t ret_ref = 0;
35370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35373         ret_ref = (uintptr_t)ret_var.inner;
35374         if (ret_var.is_owned) {
35375                 ret_ref |= 1;
35376         }
35377         return ret_ref;
35378 }
35379
35380 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
35381         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
35382 int64_t ret_ref = 0;
35383 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35384 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35385 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35386 ret_ref = (uintptr_t)ret_var.inner;
35387 if (ret_var.is_owned) {
35388         ret_ref |= 1;
35389 }
35390         return ret_ref;
35391 }
35392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35393         LDKChannelUpdate arg_conv;
35394         arg_conv.inner = (void*)(arg & (~1));
35395         arg_conv.is_owned = false;
35396         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35397         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
35398         return ret_conv;
35399 }
35400
35401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35402         LDKChannelUpdate orig_conv;
35403         orig_conv.inner = (void*)(orig & (~1));
35404         orig_conv.is_owned = false;
35405         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35406         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
35407         int64_t ret_ref = 0;
35408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35411         ret_ref = (uintptr_t)ret_var.inner;
35412         if (ret_var.is_owned) {
35413                 ret_ref |= 1;
35414         }
35415         return ret_ref;
35416 }
35417
35418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35419         LDKQueryChannelRange this_obj_conv;
35420         this_obj_conv.inner = (void*)(this_obj & (~1));
35421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35423         QueryChannelRange_free(this_obj_conv);
35424 }
35425
35426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35427         LDKQueryChannelRange this_ptr_conv;
35428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35429         this_ptr_conv.is_owned = false;
35430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35431         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35432         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
35433         return ret_arr;
35434 }
35435
35436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35437         LDKQueryChannelRange this_ptr_conv;
35438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35439         this_ptr_conv.is_owned = false;
35440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35441         LDKThirtyTwoBytes val_ref;
35442         CHECK((*env)->GetArrayLength(env, val) == 32);
35443         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35444         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
35445 }
35446
35447 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
35448         LDKQueryChannelRange this_ptr_conv;
35449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35450         this_ptr_conv.is_owned = false;
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35452         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
35453         return ret_conv;
35454 }
35455
35456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35457         LDKQueryChannelRange this_ptr_conv;
35458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35459         this_ptr_conv.is_owned = false;
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35461         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
35462 }
35463
35464 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
35465         LDKQueryChannelRange this_ptr_conv;
35466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35467         this_ptr_conv.is_owned = false;
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35469         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
35470         return ret_conv;
35471 }
35472
35473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35474         LDKQueryChannelRange this_ptr_conv;
35475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35476         this_ptr_conv.is_owned = false;
35477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35478         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
35479 }
35480
35481 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) {
35482         LDKThirtyTwoBytes chain_hash_arg_ref;
35483         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35484         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35485         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
35486         int64_t ret_ref = 0;
35487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35490         ret_ref = (uintptr_t)ret_var.inner;
35491         if (ret_var.is_owned) {
35492                 ret_ref |= 1;
35493         }
35494         return ret_ref;
35495 }
35496
35497 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
35498         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
35499 int64_t ret_ref = 0;
35500 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35501 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35502 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35503 ret_ref = (uintptr_t)ret_var.inner;
35504 if (ret_var.is_owned) {
35505         ret_ref |= 1;
35506 }
35507         return ret_ref;
35508 }
35509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35510         LDKQueryChannelRange arg_conv;
35511         arg_conv.inner = (void*)(arg & (~1));
35512         arg_conv.is_owned = false;
35513         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35514         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
35515         return ret_conv;
35516 }
35517
35518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35519         LDKQueryChannelRange orig_conv;
35520         orig_conv.inner = (void*)(orig & (~1));
35521         orig_conv.is_owned = false;
35522         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35523         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
35524         int64_t ret_ref = 0;
35525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35528         ret_ref = (uintptr_t)ret_var.inner;
35529         if (ret_var.is_owned) {
35530                 ret_ref |= 1;
35531         }
35532         return ret_ref;
35533 }
35534
35535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35536         LDKReplyChannelRange this_obj_conv;
35537         this_obj_conv.inner = (void*)(this_obj & (~1));
35538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35540         ReplyChannelRange_free(this_obj_conv);
35541 }
35542
35543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35544         LDKReplyChannelRange this_ptr_conv;
35545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35546         this_ptr_conv.is_owned = false;
35547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35548         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35549         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
35550         return ret_arr;
35551 }
35552
35553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35554         LDKReplyChannelRange this_ptr_conv;
35555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35556         this_ptr_conv.is_owned = false;
35557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35558         LDKThirtyTwoBytes val_ref;
35559         CHECK((*env)->GetArrayLength(env, val) == 32);
35560         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35561         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
35562 }
35563
35564 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
35565         LDKReplyChannelRange this_ptr_conv;
35566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35567         this_ptr_conv.is_owned = false;
35568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35569         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
35570         return ret_conv;
35571 }
35572
35573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35574         LDKReplyChannelRange this_ptr_conv;
35575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35576         this_ptr_conv.is_owned = false;
35577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35578         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
35579 }
35580
35581 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
35582         LDKReplyChannelRange this_ptr_conv;
35583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35584         this_ptr_conv.is_owned = false;
35585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35586         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
35587         return ret_conv;
35588 }
35589
35590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35591         LDKReplyChannelRange this_ptr_conv;
35592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35593         this_ptr_conv.is_owned = false;
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35595         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
35596 }
35597
35598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
35599         LDKReplyChannelRange this_ptr_conv;
35600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35601         this_ptr_conv.is_owned = false;
35602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35603         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
35604         return ret_conv;
35605 }
35606
35607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35608         LDKReplyChannelRange this_ptr_conv;
35609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35610         this_ptr_conv.is_owned = false;
35611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35612         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
35613 }
35614
35615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35616         LDKReplyChannelRange this_ptr_conv;
35617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35618         this_ptr_conv.is_owned = false;
35619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35620         LDKCVec_u64Z val_constr;
35621         val_constr.datalen = (*env)->GetArrayLength(env, val);
35622         if (val_constr.datalen > 0)
35623                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35624         else
35625                 val_constr.data = NULL;
35626         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35627         for (size_t g = 0; g < val_constr.datalen; g++) {
35628                 int64_t val_conv_6 = val_vals[g];
35629                 val_constr.data[g] = val_conv_6;
35630         }
35631         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35632         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
35633 }
35634
35635 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) {
35636         LDKThirtyTwoBytes chain_hash_arg_ref;
35637         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35638         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35639         LDKCVec_u64Z short_channel_ids_arg_constr;
35640         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35641         if (short_channel_ids_arg_constr.datalen > 0)
35642                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35643         else
35644                 short_channel_ids_arg_constr.data = NULL;
35645         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35646         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35647                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35648                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35649         }
35650         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35651         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
35652         int64_t ret_ref = 0;
35653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35656         ret_ref = (uintptr_t)ret_var.inner;
35657         if (ret_var.is_owned) {
35658                 ret_ref |= 1;
35659         }
35660         return ret_ref;
35661 }
35662
35663 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
35664         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
35665 int64_t ret_ref = 0;
35666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35669 ret_ref = (uintptr_t)ret_var.inner;
35670 if (ret_var.is_owned) {
35671         ret_ref |= 1;
35672 }
35673         return ret_ref;
35674 }
35675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35676         LDKReplyChannelRange arg_conv;
35677         arg_conv.inner = (void*)(arg & (~1));
35678         arg_conv.is_owned = false;
35679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35680         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
35681         return ret_conv;
35682 }
35683
35684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35685         LDKReplyChannelRange orig_conv;
35686         orig_conv.inner = (void*)(orig & (~1));
35687         orig_conv.is_owned = false;
35688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35689         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
35690         int64_t ret_ref = 0;
35691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35694         ret_ref = (uintptr_t)ret_var.inner;
35695         if (ret_var.is_owned) {
35696                 ret_ref |= 1;
35697         }
35698         return ret_ref;
35699 }
35700
35701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35702         LDKQueryShortChannelIds this_obj_conv;
35703         this_obj_conv.inner = (void*)(this_obj & (~1));
35704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35706         QueryShortChannelIds_free(this_obj_conv);
35707 }
35708
35709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35710         LDKQueryShortChannelIds this_ptr_conv;
35711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35712         this_ptr_conv.is_owned = false;
35713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
35716         return ret_arr;
35717 }
35718
35719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35720         LDKQueryShortChannelIds this_ptr_conv;
35721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35722         this_ptr_conv.is_owned = false;
35723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35724         LDKThirtyTwoBytes val_ref;
35725         CHECK((*env)->GetArrayLength(env, val) == 32);
35726         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35727         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
35728 }
35729
35730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35731         LDKQueryShortChannelIds this_ptr_conv;
35732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35733         this_ptr_conv.is_owned = false;
35734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35735         LDKCVec_u64Z val_constr;
35736         val_constr.datalen = (*env)->GetArrayLength(env, val);
35737         if (val_constr.datalen > 0)
35738                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35739         else
35740                 val_constr.data = NULL;
35741         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35742         for (size_t g = 0; g < val_constr.datalen; g++) {
35743                 int64_t val_conv_6 = val_vals[g];
35744                 val_constr.data[g] = val_conv_6;
35745         }
35746         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35747         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
35748 }
35749
35750 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) {
35751         LDKThirtyTwoBytes chain_hash_arg_ref;
35752         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35753         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35754         LDKCVec_u64Z short_channel_ids_arg_constr;
35755         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35756         if (short_channel_ids_arg_constr.datalen > 0)
35757                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35758         else
35759                 short_channel_ids_arg_constr.data = NULL;
35760         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35761         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35762                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35763                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35764         }
35765         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35766         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
35767         int64_t ret_ref = 0;
35768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35771         ret_ref = (uintptr_t)ret_var.inner;
35772         if (ret_var.is_owned) {
35773                 ret_ref |= 1;
35774         }
35775         return ret_ref;
35776 }
35777
35778 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
35779         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
35780 int64_t ret_ref = 0;
35781 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35782 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35783 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35784 ret_ref = (uintptr_t)ret_var.inner;
35785 if (ret_var.is_owned) {
35786         ret_ref |= 1;
35787 }
35788         return ret_ref;
35789 }
35790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35791         LDKQueryShortChannelIds arg_conv;
35792         arg_conv.inner = (void*)(arg & (~1));
35793         arg_conv.is_owned = false;
35794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35795         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
35796         return ret_conv;
35797 }
35798
35799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35800         LDKQueryShortChannelIds orig_conv;
35801         orig_conv.inner = (void*)(orig & (~1));
35802         orig_conv.is_owned = false;
35803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35804         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
35805         int64_t ret_ref = 0;
35806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35809         ret_ref = (uintptr_t)ret_var.inner;
35810         if (ret_var.is_owned) {
35811                 ret_ref |= 1;
35812         }
35813         return ret_ref;
35814 }
35815
35816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35817         LDKReplyShortChannelIdsEnd this_obj_conv;
35818         this_obj_conv.inner = (void*)(this_obj & (~1));
35819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35821         ReplyShortChannelIdsEnd_free(this_obj_conv);
35822 }
35823
35824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35825         LDKReplyShortChannelIdsEnd this_ptr_conv;
35826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35827         this_ptr_conv.is_owned = false;
35828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35829         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
35831         return ret_arr;
35832 }
35833
35834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35835         LDKReplyShortChannelIdsEnd this_ptr_conv;
35836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35837         this_ptr_conv.is_owned = false;
35838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35839         LDKThirtyTwoBytes val_ref;
35840         CHECK((*env)->GetArrayLength(env, val) == 32);
35841         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35842         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
35843 }
35844
35845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
35846         LDKReplyShortChannelIdsEnd this_ptr_conv;
35847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35848         this_ptr_conv.is_owned = false;
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35850         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
35851         return ret_conv;
35852 }
35853
35854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35855         LDKReplyShortChannelIdsEnd this_ptr_conv;
35856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35857         this_ptr_conv.is_owned = false;
35858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35859         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
35860 }
35861
35862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
35863         LDKThirtyTwoBytes chain_hash_arg_ref;
35864         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35865         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35866         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
35867         int64_t ret_ref = 0;
35868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35871         ret_ref = (uintptr_t)ret_var.inner;
35872         if (ret_var.is_owned) {
35873                 ret_ref |= 1;
35874         }
35875         return ret_ref;
35876 }
35877
35878 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
35879         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
35880 int64_t ret_ref = 0;
35881 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35882 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35883 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35884 ret_ref = (uintptr_t)ret_var.inner;
35885 if (ret_var.is_owned) {
35886         ret_ref |= 1;
35887 }
35888         return ret_ref;
35889 }
35890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35891         LDKReplyShortChannelIdsEnd arg_conv;
35892         arg_conv.inner = (void*)(arg & (~1));
35893         arg_conv.is_owned = false;
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35895         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
35896         return ret_conv;
35897 }
35898
35899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35900         LDKReplyShortChannelIdsEnd orig_conv;
35901         orig_conv.inner = (void*)(orig & (~1));
35902         orig_conv.is_owned = false;
35903         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35904         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
35905         int64_t ret_ref = 0;
35906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35909         ret_ref = (uintptr_t)ret_var.inner;
35910         if (ret_var.is_owned) {
35911                 ret_ref |= 1;
35912         }
35913         return ret_ref;
35914 }
35915
35916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35917         LDKGossipTimestampFilter this_obj_conv;
35918         this_obj_conv.inner = (void*)(this_obj & (~1));
35919         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35921         GossipTimestampFilter_free(this_obj_conv);
35922 }
35923
35924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35925         LDKGossipTimestampFilter this_ptr_conv;
35926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35927         this_ptr_conv.is_owned = false;
35928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35929         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
35931         return ret_arr;
35932 }
35933
35934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35935         LDKGossipTimestampFilter this_ptr_conv;
35936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35937         this_ptr_conv.is_owned = false;
35938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35939         LDKThirtyTwoBytes val_ref;
35940         CHECK((*env)->GetArrayLength(env, val) == 32);
35941         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35942         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
35943 }
35944
35945 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35946         LDKGossipTimestampFilter this_ptr_conv;
35947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35948         this_ptr_conv.is_owned = false;
35949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35950         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
35951         return ret_conv;
35952 }
35953
35954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35955         LDKGossipTimestampFilter this_ptr_conv;
35956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35957         this_ptr_conv.is_owned = false;
35958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35959         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
35960 }
35961
35962 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
35963         LDKGossipTimestampFilter this_ptr_conv;
35964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35965         this_ptr_conv.is_owned = false;
35966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35967         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
35968         return ret_conv;
35969 }
35970
35971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35972         LDKGossipTimestampFilter this_ptr_conv;
35973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35974         this_ptr_conv.is_owned = false;
35975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35976         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
35977 }
35978
35979 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) {
35980         LDKThirtyTwoBytes chain_hash_arg_ref;
35981         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35982         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35983         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
35984         int64_t ret_ref = 0;
35985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35988         ret_ref = (uintptr_t)ret_var.inner;
35989         if (ret_var.is_owned) {
35990                 ret_ref |= 1;
35991         }
35992         return ret_ref;
35993 }
35994
35995 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
35996         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
35997 int64_t ret_ref = 0;
35998 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35999 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36000 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36001 ret_ref = (uintptr_t)ret_var.inner;
36002 if (ret_var.is_owned) {
36003         ret_ref |= 1;
36004 }
36005         return ret_ref;
36006 }
36007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36008         LDKGossipTimestampFilter arg_conv;
36009         arg_conv.inner = (void*)(arg & (~1));
36010         arg_conv.is_owned = false;
36011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36012         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
36013         return ret_conv;
36014 }
36015
36016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36017         LDKGossipTimestampFilter orig_conv;
36018         orig_conv.inner = (void*)(orig & (~1));
36019         orig_conv.is_owned = false;
36020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36021         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
36022         int64_t ret_ref = 0;
36023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36026         ret_ref = (uintptr_t)ret_var.inner;
36027         if (ret_var.is_owned) {
36028                 ret_ref |= 1;
36029         }
36030         return ret_ref;
36031 }
36032
36033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36034         if ((this_ptr & 1) != 0) return;
36035         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36036         CHECK_ACCESS(this_ptr_ptr);
36037         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
36038         FREE((void*)this_ptr);
36039         ErrorAction_free(this_ptr_conv);
36040 }
36041
36042 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
36043         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36044         *ret_copy = ErrorAction_clone(arg);
36045 int64_t ret_ref = (uintptr_t)ret_copy;
36046         return ret_ref;
36047 }
36048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36049         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
36050         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
36051         return ret_conv;
36052 }
36053
36054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36055         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
36056         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36057         *ret_copy = ErrorAction_clone(orig_conv);
36058         int64_t ret_ref = (uintptr_t)ret_copy;
36059         return ret_ref;
36060 }
36061
36062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
36063         LDKErrorMessage msg_conv;
36064         msg_conv.inner = (void*)(msg & (~1));
36065         msg_conv.is_owned = (msg & 1) || (msg == 0);
36066         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36067         msg_conv = ErrorMessage_clone(&msg_conv);
36068         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36069         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
36070         int64_t ret_ref = (uintptr_t)ret_copy;
36071         return ret_ref;
36072 }
36073
36074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
36075         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36076         *ret_copy = ErrorAction_ignore_error();
36077         int64_t ret_ref = (uintptr_t)ret_copy;
36078         return ret_ref;
36079 }
36080
36081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
36082         LDKLevel a_conv = LDKLevel_from_java(env, a);
36083         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36084         *ret_copy = ErrorAction_ignore_and_log(a_conv);
36085         int64_t ret_ref = (uintptr_t)ret_copy;
36086         return ret_ref;
36087 }
36088
36089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
36090         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36091         *ret_copy = ErrorAction_ignore_duplicate_gossip();
36092         int64_t ret_ref = (uintptr_t)ret_copy;
36093         return ret_ref;
36094 }
36095
36096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
36097         LDKErrorMessage msg_conv;
36098         msg_conv.inner = (void*)(msg & (~1));
36099         msg_conv.is_owned = (msg & 1) || (msg == 0);
36100         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36101         msg_conv = ErrorMessage_clone(&msg_conv);
36102         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36103         *ret_copy = ErrorAction_send_error_message(msg_conv);
36104         int64_t ret_ref = (uintptr_t)ret_copy;
36105         return ret_ref;
36106 }
36107
36108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
36109         LDKWarningMessage msg_conv;
36110         msg_conv.inner = (void*)(msg & (~1));
36111         msg_conv.is_owned = (msg & 1) || (msg == 0);
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36113         msg_conv = WarningMessage_clone(&msg_conv);
36114         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
36115         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36116         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
36117         int64_t ret_ref = (uintptr_t)ret_copy;
36118         return ret_ref;
36119 }
36120
36121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36122         LDKLightningError this_obj_conv;
36123         this_obj_conv.inner = (void*)(this_obj & (~1));
36124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36126         LightningError_free(this_obj_conv);
36127 }
36128
36129 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
36130         LDKLightningError this_ptr_conv;
36131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36132         this_ptr_conv.is_owned = false;
36133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36134         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
36135         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
36136         Str_free(ret_str);
36137         return ret_conv;
36138 }
36139
36140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
36141         LDKLightningError this_ptr_conv;
36142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36143         this_ptr_conv.is_owned = false;
36144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36145         LDKStr val_conv = java_to_owned_str(env, val);
36146         LightningError_set_err(&this_ptr_conv, val_conv);
36147 }
36148
36149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
36150         LDKLightningError this_ptr_conv;
36151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36152         this_ptr_conv.is_owned = false;
36153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36154         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36155         *ret_copy = LightningError_get_action(&this_ptr_conv);
36156         int64_t ret_ref = (uintptr_t)ret_copy;
36157         return ret_ref;
36158 }
36159
36160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36161         LDKLightningError this_ptr_conv;
36162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36163         this_ptr_conv.is_owned = false;
36164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36165         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36166         CHECK_ACCESS(val_ptr);
36167         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
36168         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
36169         LightningError_set_action(&this_ptr_conv, val_conv);
36170 }
36171
36172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
36173         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
36174         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
36175         CHECK_ACCESS(action_arg_ptr);
36176         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
36177         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
36178         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
36179         int64_t ret_ref = 0;
36180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36183         ret_ref = (uintptr_t)ret_var.inner;
36184         if (ret_var.is_owned) {
36185                 ret_ref |= 1;
36186         }
36187         return ret_ref;
36188 }
36189
36190 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
36191         LDKLightningError ret_var = LightningError_clone(arg);
36192 int64_t ret_ref = 0;
36193 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36194 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36195 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36196 ret_ref = (uintptr_t)ret_var.inner;
36197 if (ret_var.is_owned) {
36198         ret_ref |= 1;
36199 }
36200         return ret_ref;
36201 }
36202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36203         LDKLightningError arg_conv;
36204         arg_conv.inner = (void*)(arg & (~1));
36205         arg_conv.is_owned = false;
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36207         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
36208         return ret_conv;
36209 }
36210
36211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36212         LDKLightningError orig_conv;
36213         orig_conv.inner = (void*)(orig & (~1));
36214         orig_conv.is_owned = false;
36215         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36216         LDKLightningError ret_var = LightningError_clone(&orig_conv);
36217         int64_t ret_ref = 0;
36218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36221         ret_ref = (uintptr_t)ret_var.inner;
36222         if (ret_var.is_owned) {
36223                 ret_ref |= 1;
36224         }
36225         return ret_ref;
36226 }
36227
36228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36229         LDKCommitmentUpdate this_obj_conv;
36230         this_obj_conv.inner = (void*)(this_obj & (~1));
36231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36233         CommitmentUpdate_free(this_obj_conv);
36234 }
36235
36236 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36237         LDKCommitmentUpdate this_ptr_conv;
36238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36239         this_ptr_conv.is_owned = false;
36240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36241         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
36242         int64_tArray ret_arr = NULL;
36243         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36244         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36245         for (size_t p = 0; p < ret_var.datalen; p++) {
36246                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
36247                 int64_t ret_conv_15_ref = 0;
36248                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36249                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36250                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
36251                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
36252                 if (ret_conv_15_var.is_owned) {
36253                         ret_conv_15_ref |= 1;
36254                 }
36255                 ret_arr_ptr[p] = ret_conv_15_ref;
36256         }
36257         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36258         FREE(ret_var.data);
36259         return ret_arr;
36260 }
36261
36262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36263         LDKCommitmentUpdate this_ptr_conv;
36264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36265         this_ptr_conv.is_owned = false;
36266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36267         LDKCVec_UpdateAddHTLCZ val_constr;
36268         val_constr.datalen = (*env)->GetArrayLength(env, val);
36269         if (val_constr.datalen > 0)
36270                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
36271         else
36272                 val_constr.data = NULL;
36273         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36274         for (size_t p = 0; p < val_constr.datalen; p++) {
36275                 int64_t val_conv_15 = val_vals[p];
36276                 LDKUpdateAddHTLC val_conv_15_conv;
36277                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
36278                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
36279                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
36280                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
36281                 val_constr.data[p] = val_conv_15_conv;
36282         }
36283         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36284         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
36285 }
36286
36287 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36288         LDKCommitmentUpdate this_ptr_conv;
36289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36290         this_ptr_conv.is_owned = false;
36291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36292         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
36293         int64_tArray ret_arr = NULL;
36294         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36295         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36296         for (size_t t = 0; t < ret_var.datalen; t++) {
36297                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
36298                 int64_t ret_conv_19_ref = 0;
36299                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36300                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36301                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
36302                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
36303                 if (ret_conv_19_var.is_owned) {
36304                         ret_conv_19_ref |= 1;
36305                 }
36306                 ret_arr_ptr[t] = ret_conv_19_ref;
36307         }
36308         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36309         FREE(ret_var.data);
36310         return ret_arr;
36311 }
36312
36313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36314         LDKCommitmentUpdate this_ptr_conv;
36315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36316         this_ptr_conv.is_owned = false;
36317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36318         LDKCVec_UpdateFulfillHTLCZ val_constr;
36319         val_constr.datalen = (*env)->GetArrayLength(env, val);
36320         if (val_constr.datalen > 0)
36321                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
36322         else
36323                 val_constr.data = NULL;
36324         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36325         for (size_t t = 0; t < val_constr.datalen; t++) {
36326                 int64_t val_conv_19 = val_vals[t];
36327                 LDKUpdateFulfillHTLC val_conv_19_conv;
36328                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
36329                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
36330                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
36331                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
36332                 val_constr.data[t] = val_conv_19_conv;
36333         }
36334         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36335         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
36336 }
36337
36338 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36339         LDKCommitmentUpdate this_ptr_conv;
36340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36341         this_ptr_conv.is_owned = false;
36342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36343         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
36344         int64_tArray ret_arr = NULL;
36345         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36346         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36347         for (size_t q = 0; q < ret_var.datalen; q++) {
36348                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
36349                 int64_t ret_conv_16_ref = 0;
36350                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36351                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36352                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
36353                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
36354                 if (ret_conv_16_var.is_owned) {
36355                         ret_conv_16_ref |= 1;
36356                 }
36357                 ret_arr_ptr[q] = ret_conv_16_ref;
36358         }
36359         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36360         FREE(ret_var.data);
36361         return ret_arr;
36362 }
36363
36364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36365         LDKCommitmentUpdate this_ptr_conv;
36366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36367         this_ptr_conv.is_owned = false;
36368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36369         LDKCVec_UpdateFailHTLCZ val_constr;
36370         val_constr.datalen = (*env)->GetArrayLength(env, val);
36371         if (val_constr.datalen > 0)
36372                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
36373         else
36374                 val_constr.data = NULL;
36375         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36376         for (size_t q = 0; q < val_constr.datalen; q++) {
36377                 int64_t val_conv_16 = val_vals[q];
36378                 LDKUpdateFailHTLC val_conv_16_conv;
36379                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
36380                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
36381                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
36382                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
36383                 val_constr.data[q] = val_conv_16_conv;
36384         }
36385         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36386         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
36387 }
36388
36389 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36390         LDKCommitmentUpdate this_ptr_conv;
36391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36392         this_ptr_conv.is_owned = false;
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36394         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
36395         int64_tArray ret_arr = NULL;
36396         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36397         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36398         for (size_t z = 0; z < ret_var.datalen; z++) {
36399                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
36400                 int64_t ret_conv_25_ref = 0;
36401                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36402                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36403                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
36404                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
36405                 if (ret_conv_25_var.is_owned) {
36406                         ret_conv_25_ref |= 1;
36407                 }
36408                 ret_arr_ptr[z] = ret_conv_25_ref;
36409         }
36410         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36411         FREE(ret_var.data);
36412         return ret_arr;
36413 }
36414
36415 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) {
36416         LDKCommitmentUpdate this_ptr_conv;
36417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36418         this_ptr_conv.is_owned = false;
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36420         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
36421         val_constr.datalen = (*env)->GetArrayLength(env, val);
36422         if (val_constr.datalen > 0)
36423                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
36424         else
36425                 val_constr.data = NULL;
36426         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36427         for (size_t z = 0; z < val_constr.datalen; z++) {
36428                 int64_t val_conv_25 = val_vals[z];
36429                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
36430                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
36431                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
36432                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
36433                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
36434                 val_constr.data[z] = val_conv_25_conv;
36435         }
36436         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36437         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
36438 }
36439
36440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36441         LDKCommitmentUpdate this_ptr_conv;
36442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36443         this_ptr_conv.is_owned = false;
36444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36445         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
36446         int64_t ret_ref = 0;
36447         if ((uintptr_t)ret_var.inner > 4096) {
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         }
36456         return ret_ref;
36457 }
36458
36459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36460         LDKCommitmentUpdate this_ptr_conv;
36461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36462         this_ptr_conv.is_owned = false;
36463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36464         LDKUpdateFee val_conv;
36465         val_conv.inner = (void*)(val & (~1));
36466         val_conv.is_owned = (val & 1) || (val == 0);
36467         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36468         val_conv = UpdateFee_clone(&val_conv);
36469         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
36470 }
36471
36472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
36473         LDKCommitmentUpdate this_ptr_conv;
36474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36475         this_ptr_conv.is_owned = false;
36476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36477         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
36478         int64_t ret_ref = 0;
36479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36482         ret_ref = (uintptr_t)ret_var.inner;
36483         if (ret_var.is_owned) {
36484                 ret_ref |= 1;
36485         }
36486         return ret_ref;
36487 }
36488
36489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36490         LDKCommitmentUpdate this_ptr_conv;
36491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36492         this_ptr_conv.is_owned = false;
36493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36494         LDKCommitmentSigned val_conv;
36495         val_conv.inner = (void*)(val & (~1));
36496         val_conv.is_owned = (val & 1) || (val == 0);
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36498         val_conv = CommitmentSigned_clone(&val_conv);
36499         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
36500 }
36501
36502 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) {
36503         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
36504         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
36505         if (update_add_htlcs_arg_constr.datalen > 0)
36506                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
36507         else
36508                 update_add_htlcs_arg_constr.data = NULL;
36509         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
36510         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
36511                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
36512                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
36513                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
36514                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
36515                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
36516                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
36517                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
36518         }
36519         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
36520         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
36521         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
36522         if (update_fulfill_htlcs_arg_constr.datalen > 0)
36523                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
36524         else
36525                 update_fulfill_htlcs_arg_constr.data = NULL;
36526         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
36527         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
36528                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
36529                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
36530                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
36531                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
36532                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
36533                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
36534                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
36535         }
36536         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
36537         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
36538         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
36539         if (update_fail_htlcs_arg_constr.datalen > 0)
36540                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
36541         else
36542                 update_fail_htlcs_arg_constr.data = NULL;
36543         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
36544         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
36545                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
36546                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
36547                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
36548                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
36549                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
36550                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
36551                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
36552         }
36553         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
36554         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
36555         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
36556         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
36557                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
36558         else
36559                 update_fail_malformed_htlcs_arg_constr.data = NULL;
36560         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
36561         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
36562                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
36563                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
36564                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
36565                 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);
36566                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
36567                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
36568                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
36569         }
36570         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
36571         LDKUpdateFee update_fee_arg_conv;
36572         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
36573         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
36575         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
36576         LDKCommitmentSigned commitment_signed_arg_conv;
36577         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
36578         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
36579         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
36580         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
36581         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);
36582         int64_t ret_ref = 0;
36583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36586         ret_ref = (uintptr_t)ret_var.inner;
36587         if (ret_var.is_owned) {
36588                 ret_ref |= 1;
36589         }
36590         return ret_ref;
36591 }
36592
36593 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
36594         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
36595 int64_t ret_ref = 0;
36596 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36597 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36598 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36599 ret_ref = (uintptr_t)ret_var.inner;
36600 if (ret_var.is_owned) {
36601         ret_ref |= 1;
36602 }
36603         return ret_ref;
36604 }
36605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36606         LDKCommitmentUpdate arg_conv;
36607         arg_conv.inner = (void*)(arg & (~1));
36608         arg_conv.is_owned = false;
36609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36610         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
36611         return ret_conv;
36612 }
36613
36614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36615         LDKCommitmentUpdate orig_conv;
36616         orig_conv.inner = (void*)(orig & (~1));
36617         orig_conv.is_owned = false;
36618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36619         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
36620         int64_t ret_ref = 0;
36621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36624         ret_ref = (uintptr_t)ret_var.inner;
36625         if (ret_var.is_owned) {
36626                 ret_ref |= 1;
36627         }
36628         return ret_ref;
36629 }
36630
36631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36632         if ((this_ptr & 1) != 0) return;
36633         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36634         CHECK_ACCESS(this_ptr_ptr);
36635         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
36636         FREE((void*)this_ptr);
36637         ChannelMessageHandler_free(this_ptr_conv);
36638 }
36639
36640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36641         if ((this_ptr & 1) != 0) return;
36642         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36643         CHECK_ACCESS(this_ptr_ptr);
36644         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
36645         FREE((void*)this_ptr);
36646         RoutingMessageHandler_free(this_ptr_conv);
36647 }
36648
36649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36650         LDKAcceptChannel obj_conv;
36651         obj_conv.inner = (void*)(obj & (~1));
36652         obj_conv.is_owned = false;
36653         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36654         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
36655         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36656         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36657         CVec_u8Z_free(ret_var);
36658         return ret_arr;
36659 }
36660
36661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36662         LDKu8slice ser_ref;
36663         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36664         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36665         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
36666         *ret_conv = AcceptChannel_read(ser_ref);
36667         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36668         return (int64_t)ret_conv;
36669 }
36670
36671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36672         LDKAnnouncementSignatures obj_conv;
36673         obj_conv.inner = (void*)(obj & (~1));
36674         obj_conv.is_owned = false;
36675         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36676         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
36677         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36678         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36679         CVec_u8Z_free(ret_var);
36680         return ret_arr;
36681 }
36682
36683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36684         LDKu8slice ser_ref;
36685         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36686         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36687         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
36688         *ret_conv = AnnouncementSignatures_read(ser_ref);
36689         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36690         return (int64_t)ret_conv;
36691 }
36692
36693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
36694         LDKChannelReestablish obj_conv;
36695         obj_conv.inner = (void*)(obj & (~1));
36696         obj_conv.is_owned = false;
36697         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36698         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
36699         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36700         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36701         CVec_u8Z_free(ret_var);
36702         return ret_arr;
36703 }
36704
36705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36706         LDKu8slice ser_ref;
36707         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36708         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36709         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
36710         *ret_conv = ChannelReestablish_read(ser_ref);
36711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36712         return (int64_t)ret_conv;
36713 }
36714
36715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36716         LDKClosingSigned obj_conv;
36717         obj_conv.inner = (void*)(obj & (~1));
36718         obj_conv.is_owned = false;
36719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36720         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
36721         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36722         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36723         CVec_u8Z_free(ret_var);
36724         return ret_arr;
36725 }
36726
36727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36728         LDKu8slice ser_ref;
36729         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36730         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36731         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
36732         *ret_conv = ClosingSigned_read(ser_ref);
36733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36734         return (int64_t)ret_conv;
36735 }
36736
36737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36738         LDKClosingSignedFeeRange obj_conv;
36739         obj_conv.inner = (void*)(obj & (~1));
36740         obj_conv.is_owned = false;
36741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36742         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
36743         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36744         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36745         CVec_u8Z_free(ret_var);
36746         return ret_arr;
36747 }
36748
36749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36750         LDKu8slice ser_ref;
36751         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36752         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36753         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
36754         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
36755         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36756         return (int64_t)ret_conv;
36757 }
36758
36759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36760         LDKCommitmentSigned obj_conv;
36761         obj_conv.inner = (void*)(obj & (~1));
36762         obj_conv.is_owned = false;
36763         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36764         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
36765         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36766         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36767         CVec_u8Z_free(ret_var);
36768         return ret_arr;
36769 }
36770
36771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36772         LDKu8slice ser_ref;
36773         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36774         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36775         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
36776         *ret_conv = CommitmentSigned_read(ser_ref);
36777         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36778         return (int64_t)ret_conv;
36779 }
36780
36781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
36782         LDKFundingCreated obj_conv;
36783         obj_conv.inner = (void*)(obj & (~1));
36784         obj_conv.is_owned = false;
36785         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36786         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
36787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36789         CVec_u8Z_free(ret_var);
36790         return ret_arr;
36791 }
36792
36793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36794         LDKu8slice ser_ref;
36795         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36796         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36797         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
36798         *ret_conv = FundingCreated_read(ser_ref);
36799         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36800         return (int64_t)ret_conv;
36801 }
36802
36803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36804         LDKFundingSigned obj_conv;
36805         obj_conv.inner = (void*)(obj & (~1));
36806         obj_conv.is_owned = false;
36807         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36808         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
36809         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36810         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36811         CVec_u8Z_free(ret_var);
36812         return ret_arr;
36813 }
36814
36815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36816         LDKu8slice ser_ref;
36817         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36818         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36819         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
36820         *ret_conv = FundingSigned_read(ser_ref);
36821         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36822         return (int64_t)ret_conv;
36823 }
36824
36825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
36826         LDKChannelReady obj_conv;
36827         obj_conv.inner = (void*)(obj & (~1));
36828         obj_conv.is_owned = false;
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36830         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
36831         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36832         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36833         CVec_u8Z_free(ret_var);
36834         return ret_arr;
36835 }
36836
36837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36838         LDKu8slice ser_ref;
36839         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36840         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36841         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
36842         *ret_conv = ChannelReady_read(ser_ref);
36843         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36844         return (int64_t)ret_conv;
36845 }
36846
36847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
36848         LDKInit obj_conv;
36849         obj_conv.inner = (void*)(obj & (~1));
36850         obj_conv.is_owned = false;
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36852         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
36853         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36854         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36855         CVec_u8Z_free(ret_var);
36856         return ret_arr;
36857 }
36858
36859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36860         LDKu8slice ser_ref;
36861         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36862         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36863         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
36864         *ret_conv = Init_read(ser_ref);
36865         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36866         return (int64_t)ret_conv;
36867 }
36868
36869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36870         LDKOpenChannel obj_conv;
36871         obj_conv.inner = (void*)(obj & (~1));
36872         obj_conv.is_owned = false;
36873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36874         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
36875         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36876         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36877         CVec_u8Z_free(ret_var);
36878         return ret_arr;
36879 }
36880
36881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36882         LDKu8slice ser_ref;
36883         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36884         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36885         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
36886         *ret_conv = OpenChannel_read(ser_ref);
36887         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36888         return (int64_t)ret_conv;
36889 }
36890
36891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
36892         LDKRevokeAndACK obj_conv;
36893         obj_conv.inner = (void*)(obj & (~1));
36894         obj_conv.is_owned = false;
36895         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36896         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
36897         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36898         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36899         CVec_u8Z_free(ret_var);
36900         return ret_arr;
36901 }
36902
36903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36904         LDKu8slice ser_ref;
36905         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36906         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36907         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
36908         *ret_conv = RevokeAndACK_read(ser_ref);
36909         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36910         return (int64_t)ret_conv;
36911 }
36912
36913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
36914         LDKShutdown obj_conv;
36915         obj_conv.inner = (void*)(obj & (~1));
36916         obj_conv.is_owned = false;
36917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36918         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
36919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36921         CVec_u8Z_free(ret_var);
36922         return ret_arr;
36923 }
36924
36925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36926         LDKu8slice ser_ref;
36927         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36928         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36929         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
36930         *ret_conv = Shutdown_read(ser_ref);
36931         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36932         return (int64_t)ret_conv;
36933 }
36934
36935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36936         LDKUpdateFailHTLC obj_conv;
36937         obj_conv.inner = (void*)(obj & (~1));
36938         obj_conv.is_owned = false;
36939         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36940         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
36941         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36942         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36943         CVec_u8Z_free(ret_var);
36944         return ret_arr;
36945 }
36946
36947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36948         LDKu8slice ser_ref;
36949         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36950         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36951         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
36952         *ret_conv = UpdateFailHTLC_read(ser_ref);
36953         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36954         return (int64_t)ret_conv;
36955 }
36956
36957 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36958         LDKUpdateFailMalformedHTLC obj_conv;
36959         obj_conv.inner = (void*)(obj & (~1));
36960         obj_conv.is_owned = false;
36961         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36962         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
36963         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36964         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36965         CVec_u8Z_free(ret_var);
36966         return ret_arr;
36967 }
36968
36969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36970         LDKu8slice ser_ref;
36971         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36972         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36973         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
36974         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
36975         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36976         return (int64_t)ret_conv;
36977 }
36978
36979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
36980         LDKUpdateFee obj_conv;
36981         obj_conv.inner = (void*)(obj & (~1));
36982         obj_conv.is_owned = false;
36983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36984         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
36985         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36986         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36987         CVec_u8Z_free(ret_var);
36988         return ret_arr;
36989 }
36990
36991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36992         LDKu8slice ser_ref;
36993         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36994         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36995         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
36996         *ret_conv = UpdateFee_read(ser_ref);
36997         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36998         return (int64_t)ret_conv;
36999 }
37000
37001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37002         LDKUpdateFulfillHTLC obj_conv;
37003         obj_conv.inner = (void*)(obj & (~1));
37004         obj_conv.is_owned = false;
37005         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37006         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
37007         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37008         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37009         CVec_u8Z_free(ret_var);
37010         return ret_arr;
37011 }
37012
37013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37014         LDKu8slice ser_ref;
37015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37017         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
37018         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
37019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37020         return (int64_t)ret_conv;
37021 }
37022
37023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37024         LDKUpdateAddHTLC obj_conv;
37025         obj_conv.inner = (void*)(obj & (~1));
37026         obj_conv.is_owned = false;
37027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37028         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
37029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37031         CVec_u8Z_free(ret_var);
37032         return ret_arr;
37033 }
37034
37035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37036         LDKu8slice ser_ref;
37037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37039         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
37040         *ret_conv = UpdateAddHTLC_read(ser_ref);
37041         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37042         return (int64_t)ret_conv;
37043 }
37044
37045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
37046         LDKPing obj_conv;
37047         obj_conv.inner = (void*)(obj & (~1));
37048         obj_conv.is_owned = false;
37049         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37050         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
37051         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37052         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37053         CVec_u8Z_free(ret_var);
37054         return ret_arr;
37055 }
37056
37057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37058         LDKu8slice ser_ref;
37059         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37060         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37061         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
37062         *ret_conv = Ping_read(ser_ref);
37063         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37064         return (int64_t)ret_conv;
37065 }
37066
37067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
37068         LDKPong obj_conv;
37069         obj_conv.inner = (void*)(obj & (~1));
37070         obj_conv.is_owned = false;
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37072         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
37073         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37074         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37075         CVec_u8Z_free(ret_var);
37076         return ret_arr;
37077 }
37078
37079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37080         LDKu8slice ser_ref;
37081         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37082         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37083         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
37084         *ret_conv = Pong_read(ser_ref);
37085         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37086         return (int64_t)ret_conv;
37087 }
37088
37089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37090         LDKUnsignedChannelAnnouncement obj_conv;
37091         obj_conv.inner = (void*)(obj & (~1));
37092         obj_conv.is_owned = false;
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37094         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
37095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37097         CVec_u8Z_free(ret_var);
37098         return ret_arr;
37099 }
37100
37101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37102         LDKu8slice ser_ref;
37103         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37104         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37105         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
37106         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
37107         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37108         return (int64_t)ret_conv;
37109 }
37110
37111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37112         LDKChannelAnnouncement obj_conv;
37113         obj_conv.inner = (void*)(obj & (~1));
37114         obj_conv.is_owned = false;
37115         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37116         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
37117         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37118         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37119         CVec_u8Z_free(ret_var);
37120         return ret_arr;
37121 }
37122
37123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37124         LDKu8slice ser_ref;
37125         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37126         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37127         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
37128         *ret_conv = ChannelAnnouncement_read(ser_ref);
37129         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37130         return (int64_t)ret_conv;
37131 }
37132
37133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37134         LDKUnsignedChannelUpdate obj_conv;
37135         obj_conv.inner = (void*)(obj & (~1));
37136         obj_conv.is_owned = false;
37137         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37138         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
37139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37141         CVec_u8Z_free(ret_var);
37142         return ret_arr;
37143 }
37144
37145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37146         LDKu8slice ser_ref;
37147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37149         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
37150         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
37151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37152         return (int64_t)ret_conv;
37153 }
37154
37155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37156         LDKChannelUpdate obj_conv;
37157         obj_conv.inner = (void*)(obj & (~1));
37158         obj_conv.is_owned = false;
37159         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37160         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
37161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37163         CVec_u8Z_free(ret_var);
37164         return ret_arr;
37165 }
37166
37167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37168         LDKu8slice ser_ref;
37169         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37170         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37171         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
37172         *ret_conv = ChannelUpdate_read(ser_ref);
37173         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37174         return (int64_t)ret_conv;
37175 }
37176
37177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37178         LDKErrorMessage obj_conv;
37179         obj_conv.inner = (void*)(obj & (~1));
37180         obj_conv.is_owned = false;
37181         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37182         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
37183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37185         CVec_u8Z_free(ret_var);
37186         return ret_arr;
37187 }
37188
37189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37190         LDKu8slice ser_ref;
37191         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37192         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37193         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
37194         *ret_conv = ErrorMessage_read(ser_ref);
37195         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37196         return (int64_t)ret_conv;
37197 }
37198
37199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37200         LDKWarningMessage obj_conv;
37201         obj_conv.inner = (void*)(obj & (~1));
37202         obj_conv.is_owned = false;
37203         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37204         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
37205         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37206         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37207         CVec_u8Z_free(ret_var);
37208         return ret_arr;
37209 }
37210
37211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37212         LDKu8slice ser_ref;
37213         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37214         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37215         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
37216         *ret_conv = WarningMessage_read(ser_ref);
37217         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37218         return (int64_t)ret_conv;
37219 }
37220
37221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37222         LDKUnsignedNodeAnnouncement obj_conv;
37223         obj_conv.inner = (void*)(obj & (~1));
37224         obj_conv.is_owned = false;
37225         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37226         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
37227         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37228         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37229         CVec_u8Z_free(ret_var);
37230         return ret_arr;
37231 }
37232
37233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37234         LDKu8slice ser_ref;
37235         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37236         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37237         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
37238         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
37239         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37240         return (int64_t)ret_conv;
37241 }
37242
37243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37244         LDKNodeAnnouncement obj_conv;
37245         obj_conv.inner = (void*)(obj & (~1));
37246         obj_conv.is_owned = false;
37247         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37248         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
37249         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37250         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37251         CVec_u8Z_free(ret_var);
37252         return ret_arr;
37253 }
37254
37255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37256         LDKu8slice ser_ref;
37257         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37258         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37259         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
37260         *ret_conv = NodeAnnouncement_read(ser_ref);
37261         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37262         return (int64_t)ret_conv;
37263 }
37264
37265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37266         LDKu8slice ser_ref;
37267         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37268         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37269         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
37270         *ret_conv = QueryShortChannelIds_read(ser_ref);
37271         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37272         return (int64_t)ret_conv;
37273 }
37274
37275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
37276         LDKQueryShortChannelIds obj_conv;
37277         obj_conv.inner = (void*)(obj & (~1));
37278         obj_conv.is_owned = false;
37279         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37280         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
37281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37283         CVec_u8Z_free(ret_var);
37284         return ret_arr;
37285 }
37286
37287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
37288         LDKReplyShortChannelIdsEnd obj_conv;
37289         obj_conv.inner = (void*)(obj & (~1));
37290         obj_conv.is_owned = false;
37291         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37292         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
37293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37295         CVec_u8Z_free(ret_var);
37296         return ret_arr;
37297 }
37298
37299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37300         LDKu8slice ser_ref;
37301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37303         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
37304         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
37305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37306         return (int64_t)ret_conv;
37307 }
37308
37309 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
37310         LDKQueryChannelRange this_arg_conv;
37311         this_arg_conv.inner = (void*)(this_arg & (~1));
37312         this_arg_conv.is_owned = false;
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37314         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
37315         return ret_conv;
37316 }
37317
37318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37319         LDKQueryChannelRange obj_conv;
37320         obj_conv.inner = (void*)(obj & (~1));
37321         obj_conv.is_owned = false;
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37323         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
37324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37326         CVec_u8Z_free(ret_var);
37327         return ret_arr;
37328 }
37329
37330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37331         LDKu8slice ser_ref;
37332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37334         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
37335         *ret_conv = QueryChannelRange_read(ser_ref);
37336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37337         return (int64_t)ret_conv;
37338 }
37339
37340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37341         LDKu8slice ser_ref;
37342         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37343         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37344         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
37345         *ret_conv = ReplyChannelRange_read(ser_ref);
37346         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37347         return (int64_t)ret_conv;
37348 }
37349
37350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37351         LDKReplyChannelRange obj_conv;
37352         obj_conv.inner = (void*)(obj & (~1));
37353         obj_conv.is_owned = false;
37354         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37355         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
37356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37358         CVec_u8Z_free(ret_var);
37359         return ret_arr;
37360 }
37361
37362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
37363         LDKGossipTimestampFilter obj_conv;
37364         obj_conv.inner = (void*)(obj & (~1));
37365         obj_conv.is_owned = false;
37366         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37367         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
37368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37370         CVec_u8Z_free(ret_var);
37371         return ret_arr;
37372 }
37373
37374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37375         LDKu8slice ser_ref;
37376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37378         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
37379         *ret_conv = GossipTimestampFilter_read(ser_ref);
37380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37381         return (int64_t)ret_conv;
37382 }
37383
37384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37385         if ((this_ptr & 1) != 0) return;
37386         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37387         CHECK_ACCESS(this_ptr_ptr);
37388         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
37389         FREE((void*)this_ptr);
37390         CustomMessageHandler_free(this_ptr_conv);
37391 }
37392
37393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37394         LDKIgnoringMessageHandler this_obj_conv;
37395         this_obj_conv.inner = (void*)(this_obj & (~1));
37396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37398         IgnoringMessageHandler_free(this_obj_conv);
37399 }
37400
37401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
37402         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
37403         int64_t ret_ref = 0;
37404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37407         ret_ref = (uintptr_t)ret_var.inner;
37408         if (ret_var.is_owned) {
37409                 ret_ref |= 1;
37410         }
37411         return ret_ref;
37412 }
37413
37414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37415         LDKIgnoringMessageHandler this_arg_conv;
37416         this_arg_conv.inner = (void*)(this_arg & (~1));
37417         this_arg_conv.is_owned = false;
37418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37419         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37420         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
37421         return (int64_t)ret_ret;
37422 }
37423
37424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37425         LDKIgnoringMessageHandler this_arg_conv;
37426         this_arg_conv.inner = (void*)(this_arg & (~1));
37427         this_arg_conv.is_owned = false;
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37429         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
37430         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
37431         return (int64_t)ret_ret;
37432 }
37433
37434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
37435         LDKIgnoringMessageHandler this_arg_conv;
37436         this_arg_conv.inner = (void*)(this_arg & (~1));
37437         this_arg_conv.is_owned = false;
37438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37439         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
37440         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
37441         return (int64_t)ret_ret;
37442 }
37443
37444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37445         LDKIgnoringMessageHandler this_arg_conv;
37446         this_arg_conv.inner = (void*)(this_arg & (~1));
37447         this_arg_conv.is_owned = false;
37448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37449         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
37450         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
37451         return (int64_t)ret_ret;
37452 }
37453
37454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37455         LDKErroringMessageHandler this_obj_conv;
37456         this_obj_conv.inner = (void*)(this_obj & (~1));
37457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37459         ErroringMessageHandler_free(this_obj_conv);
37460 }
37461
37462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
37463         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
37464         int64_t ret_ref = 0;
37465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37468         ret_ref = (uintptr_t)ret_var.inner;
37469         if (ret_var.is_owned) {
37470                 ret_ref |= 1;
37471         }
37472         return ret_ref;
37473 }
37474
37475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37476         LDKErroringMessageHandler this_arg_conv;
37477         this_arg_conv.inner = (void*)(this_arg & (~1));
37478         this_arg_conv.is_owned = false;
37479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37480         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37481         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
37482         return (int64_t)ret_ret;
37483 }
37484
37485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37486         LDKErroringMessageHandler this_arg_conv;
37487         this_arg_conv.inner = (void*)(this_arg & (~1));
37488         this_arg_conv.is_owned = false;
37489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37490         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
37491         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
37492         return (int64_t)ret_ret;
37493 }
37494
37495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37496         LDKMessageHandler this_obj_conv;
37497         this_obj_conv.inner = (void*)(this_obj & (~1));
37498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37500         MessageHandler_free(this_obj_conv);
37501 }
37502
37503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
37504         LDKMessageHandler this_ptr_conv;
37505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37506         this_ptr_conv.is_owned = false;
37507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37508         // WARNING: This object doesn't live past this scope, needs clone!
37509         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
37510         return ret_ret;
37511 }
37512
37513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37514         LDKMessageHandler this_ptr_conv;
37515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37516         this_ptr_conv.is_owned = false;
37517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37518         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37519         CHECK_ACCESS(val_ptr);
37520         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
37521         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
37522                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37523                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
37524         }
37525         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
37526 }
37527
37528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
37529         LDKMessageHandler this_ptr_conv;
37530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37531         this_ptr_conv.is_owned = false;
37532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37533         // WARNING: This object doesn't live past this scope, needs clone!
37534         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
37535         return ret_ret;
37536 }
37537
37538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37539         LDKMessageHandler this_ptr_conv;
37540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37541         this_ptr_conv.is_owned = false;
37542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37543         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37544         CHECK_ACCESS(val_ptr);
37545         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
37546         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
37547                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37548                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
37549         }
37550         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
37551 }
37552
37553 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) {
37554         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
37555         CHECK_ACCESS(chan_handler_arg_ptr);
37556         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
37557         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
37558                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37559                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
37560         }
37561         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
37562         CHECK_ACCESS(route_handler_arg_ptr);
37563         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
37564         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
37565                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37566                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
37567         }
37568         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
37569         int64_t ret_ref = 0;
37570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37573         ret_ref = (uintptr_t)ret_var.inner;
37574         if (ret_var.is_owned) {
37575                 ret_ref |= 1;
37576         }
37577         return ret_ref;
37578 }
37579
37580 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
37581         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
37582         *ret_ret = SocketDescriptor_clone(arg);
37583         return (int64_t)ret_ret;
37584 }
37585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37586         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
37587         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
37588         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
37589         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
37590         return ret_conv;
37591 }
37592
37593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37594         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
37595         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
37596         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
37597         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
37598         *ret_ret = SocketDescriptor_clone(orig_conv);
37599         return (int64_t)ret_ret;
37600 }
37601
37602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37603         if ((this_ptr & 1) != 0) return;
37604         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37605         CHECK_ACCESS(this_ptr_ptr);
37606         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
37607         FREE((void*)this_ptr);
37608         SocketDescriptor_free(this_ptr_conv);
37609 }
37610
37611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37612         LDKPeerHandleError this_obj_conv;
37613         this_obj_conv.inner = (void*)(this_obj & (~1));
37614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37616         PeerHandleError_free(this_obj_conv);
37617 }
37618
37619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
37620         LDKPeerHandleError this_ptr_conv;
37621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37622         this_ptr_conv.is_owned = false;
37623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37624         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
37625         return ret_conv;
37626 }
37627
37628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37629         LDKPeerHandleError this_ptr_conv;
37630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37631         this_ptr_conv.is_owned = false;
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37633         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
37634 }
37635
37636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
37637         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
37638         int64_t ret_ref = 0;
37639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37642         ret_ref = (uintptr_t)ret_var.inner;
37643         if (ret_var.is_owned) {
37644                 ret_ref |= 1;
37645         }
37646         return ret_ref;
37647 }
37648
37649 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
37650         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
37651 int64_t ret_ref = 0;
37652 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37653 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37654 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37655 ret_ref = (uintptr_t)ret_var.inner;
37656 if (ret_var.is_owned) {
37657         ret_ref |= 1;
37658 }
37659         return ret_ref;
37660 }
37661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37662         LDKPeerHandleError arg_conv;
37663         arg_conv.inner = (void*)(arg & (~1));
37664         arg_conv.is_owned = false;
37665         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37666         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
37667         return ret_conv;
37668 }
37669
37670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37671         LDKPeerHandleError orig_conv;
37672         orig_conv.inner = (void*)(orig & (~1));
37673         orig_conv.is_owned = false;
37674         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37675         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
37676         int64_t ret_ref = 0;
37677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37680         ret_ref = (uintptr_t)ret_var.inner;
37681         if (ret_var.is_owned) {
37682                 ret_ref |= 1;
37683         }
37684         return ret_ref;
37685 }
37686
37687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37688         LDKPeerManager this_obj_conv;
37689         this_obj_conv.inner = (void*)(this_obj & (~1));
37690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37692         PeerManager_free(this_obj_conv);
37693 }
37694
37695 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) {
37696         LDKMessageHandler message_handler_conv;
37697         message_handler_conv.inner = (void*)(message_handler & (~1));
37698         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
37700         // WARNING: we need a move here but no clone is available for LDKMessageHandler
37701         LDKSecretKey our_node_secret_ref;
37702         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
37703         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
37704         unsigned char ephemeral_random_data_arr[32];
37705         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
37706         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
37707         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
37708         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
37709         CHECK_ACCESS(logger_ptr);
37710         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37711         if (logger_conv.free == LDKLogger_JCalls_free) {
37712                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37713                 LDKLogger_JCalls_cloned(&logger_conv);
37714         }
37715         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
37716         CHECK_ACCESS(custom_message_handler_ptr);
37717         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
37718         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
37719                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37720                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
37721         }
37722         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
37723         int64_t ret_ref = 0;
37724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37727         ret_ref = (uintptr_t)ret_var.inner;
37728         if (ret_var.is_owned) {
37729                 ret_ref |= 1;
37730         }
37731         return ret_ref;
37732 }
37733
37734 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
37735         LDKPeerManager this_arg_conv;
37736         this_arg_conv.inner = (void*)(this_arg & (~1));
37737         this_arg_conv.is_owned = false;
37738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37739         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
37740         jobjectArray ret_arr = NULL;
37741         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37742         ;
37743         for (size_t i = 0; i < ret_var.datalen; i++) {
37744                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
37745                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
37746                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37747         }
37748         
37749         FREE(ret_var.data);
37750         return ret_arr;
37751 }
37752
37753 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) {
37754         LDKPeerManager this_arg_conv;
37755         this_arg_conv.inner = (void*)(this_arg & (~1));
37756         this_arg_conv.is_owned = false;
37757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37758         LDKPublicKey their_node_id_ref;
37759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
37760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
37761         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37762         CHECK_ACCESS(descriptor_ptr);
37763         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37764         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37765                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37766                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37767         }
37768         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
37769         CHECK_ACCESS(remote_network_address_ptr);
37770         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37771         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
37772         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
37773         return (int64_t)ret_conv;
37774 }
37775
37776 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) {
37777         LDKPeerManager this_arg_conv;
37778         this_arg_conv.inner = (void*)(this_arg & (~1));
37779         this_arg_conv.is_owned = false;
37780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37781         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37782         CHECK_ACCESS(descriptor_ptr);
37783         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37784         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37785                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37786                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37787         }
37788         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
37789         CHECK_ACCESS(remote_network_address_ptr);
37790         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37791         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37792         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
37793         return (int64_t)ret_conv;
37794 }
37795
37796 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) {
37797         LDKPeerManager this_arg_conv;
37798         this_arg_conv.inner = (void*)(this_arg & (~1));
37799         this_arg_conv.is_owned = false;
37800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37801         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37802         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
37803         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37804         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37805         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
37806         return (int64_t)ret_conv;
37807 }
37808
37809 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) {
37810         LDKPeerManager this_arg_conv;
37811         this_arg_conv.inner = (void*)(this_arg & (~1));
37812         this_arg_conv.is_owned = false;
37813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37814         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
37815         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
37816         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
37817         LDKu8slice data_ref;
37818         data_ref.datalen = (*env)->GetArrayLength(env, data);
37819         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
37820         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
37821         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
37822         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
37823         return (int64_t)ret_conv;
37824 }
37825
37826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
37827         LDKPeerManager this_arg_conv;
37828         this_arg_conv.inner = (void*)(this_arg & (~1));
37829         this_arg_conv.is_owned = false;
37830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37831         PeerManager_process_events(&this_arg_conv);
37832 }
37833
37834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
37835         LDKPeerManager this_arg_conv;
37836         this_arg_conv.inner = (void*)(this_arg & (~1));
37837         this_arg_conv.is_owned = false;
37838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37839         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37840         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
37841         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37842         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
37843 }
37844
37845 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) {
37846         LDKPeerManager this_arg_conv;
37847         this_arg_conv.inner = (void*)(this_arg & (~1));
37848         this_arg_conv.is_owned = false;
37849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37850         LDKPublicKey node_id_ref;
37851         CHECK((*env)->GetArrayLength(env, node_id) == 33);
37852         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
37853         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
37854 }
37855
37856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
37857         LDKPeerManager this_arg_conv;
37858         this_arg_conv.inner = (void*)(this_arg & (~1));
37859         this_arg_conv.is_owned = false;
37860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37861         PeerManager_disconnect_all_peers(&this_arg_conv);
37862 }
37863
37864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
37865         LDKPeerManager this_arg_conv;
37866         this_arg_conv.inner = (void*)(this_arg & (~1));
37867         this_arg_conv.is_owned = false;
37868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37869         PeerManager_timer_tick_occurred(&this_arg_conv);
37870 }
37871
37872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37873         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
37874         return ret_conv;
37875 }
37876
37877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37878         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
37879         return ret_conv;
37880 }
37881
37882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
37883         unsigned char commitment_seed_arr[32];
37884         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
37885         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
37886         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
37887         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
37889         return ret_arr;
37890 }
37891
37892 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) {
37893         LDKCVec_u8Z to_holder_script_ref;
37894         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
37895         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
37896         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
37897         LDKCVec_u8Z to_counterparty_script_ref;
37898         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
37899         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
37900         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
37901         LDKOutPoint funding_outpoint_conv;
37902         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37903         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37904         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37905         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37906         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);
37907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37909         Transaction_free(ret_var);
37910         return ret_arr;
37911 }
37912
37913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37914         LDKCounterpartyCommitmentSecrets this_obj_conv;
37915         this_obj_conv.inner = (void*)(this_obj & (~1));
37916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37918         CounterpartyCommitmentSecrets_free(this_obj_conv);
37919 }
37920
37921 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
37922         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
37923 int64_t ret_ref = 0;
37924 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37925 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37926 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37927 ret_ref = (uintptr_t)ret_var.inner;
37928 if (ret_var.is_owned) {
37929         ret_ref |= 1;
37930 }
37931         return ret_ref;
37932 }
37933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37934         LDKCounterpartyCommitmentSecrets arg_conv;
37935         arg_conv.inner = (void*)(arg & (~1));
37936         arg_conv.is_owned = false;
37937         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37938         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
37939         return ret_conv;
37940 }
37941
37942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37943         LDKCounterpartyCommitmentSecrets orig_conv;
37944         orig_conv.inner = (void*)(orig & (~1));
37945         orig_conv.is_owned = false;
37946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37947         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
37948         int64_t ret_ref = 0;
37949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37952         ret_ref = (uintptr_t)ret_var.inner;
37953         if (ret_var.is_owned) {
37954                 ret_ref |= 1;
37955         }
37956         return ret_ref;
37957 }
37958
37959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
37960         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
37961         int64_t ret_ref = 0;
37962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37965         ret_ref = (uintptr_t)ret_var.inner;
37966         if (ret_var.is_owned) {
37967                 ret_ref |= 1;
37968         }
37969         return ret_ref;
37970 }
37971
37972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
37973         LDKCounterpartyCommitmentSecrets this_arg_conv;
37974         this_arg_conv.inner = (void*)(this_arg & (~1));
37975         this_arg_conv.is_owned = false;
37976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37977         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
37978         return ret_conv;
37979 }
37980
37981 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) {
37982         LDKCounterpartyCommitmentSecrets this_arg_conv;
37983         this_arg_conv.inner = (void*)(this_arg & (~1));
37984         this_arg_conv.is_owned = false;
37985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37986         LDKThirtyTwoBytes secret_ref;
37987         CHECK((*env)->GetArrayLength(env, secret) == 32);
37988         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
37989         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
37990         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
37991         return (int64_t)ret_conv;
37992 }
37993
37994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
37995         LDKCounterpartyCommitmentSecrets this_arg_conv;
37996         this_arg_conv.inner = (void*)(this_arg & (~1));
37997         this_arg_conv.is_owned = false;
37998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37999         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
38001         return ret_arr;
38002 }
38003
38004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
38005         LDKCounterpartyCommitmentSecrets obj_conv;
38006         obj_conv.inner = (void*)(obj & (~1));
38007         obj_conv.is_owned = false;
38008         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38009         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
38010         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38011         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38012         CVec_u8Z_free(ret_var);
38013         return ret_arr;
38014 }
38015
38016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38017         LDKu8slice ser_ref;
38018         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38019         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38020         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
38021         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
38022         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38023         return (int64_t)ret_conv;
38024 }
38025
38026 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) {
38027         LDKPublicKey per_commitment_point_ref;
38028         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38029         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38030         unsigned char base_secret_arr[32];
38031         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
38032         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
38033         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
38034         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38035         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
38036         return (int64_t)ret_conv;
38037 }
38038
38039 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) {
38040         LDKPublicKey per_commitment_point_ref;
38041         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38042         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38043         LDKPublicKey base_point_ref;
38044         CHECK((*env)->GetArrayLength(env, base_point) == 33);
38045         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
38046         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38047         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
38048         return (int64_t)ret_conv;
38049 }
38050
38051 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) {
38052         unsigned char per_commitment_secret_arr[32];
38053         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
38054         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
38055         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
38056         unsigned char countersignatory_revocation_base_secret_arr[32];
38057         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
38058         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
38059         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
38060         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38061         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
38062         return (int64_t)ret_conv;
38063 }
38064
38065 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) {
38066         LDKPublicKey per_commitment_point_ref;
38067         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38068         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38069         LDKPublicKey countersignatory_revocation_base_point_ref;
38070         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
38071         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
38072         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38073         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
38074         return (int64_t)ret_conv;
38075 }
38076
38077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38078         LDKTxCreationKeys this_obj_conv;
38079         this_obj_conv.inner = (void*)(this_obj & (~1));
38080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38082         TxCreationKeys_free(this_obj_conv);
38083 }
38084
38085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38086         LDKTxCreationKeys this_ptr_conv;
38087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38088         this_ptr_conv.is_owned = false;
38089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38090         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38091         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
38092         return ret_arr;
38093 }
38094
38095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38096         LDKTxCreationKeys this_ptr_conv;
38097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38098         this_ptr_conv.is_owned = false;
38099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38100         LDKPublicKey val_ref;
38101         CHECK((*env)->GetArrayLength(env, val) == 33);
38102         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38103         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
38104 }
38105
38106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38107         LDKTxCreationKeys this_ptr_conv;
38108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38109         this_ptr_conv.is_owned = false;
38110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38111         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38112         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
38113         return ret_arr;
38114 }
38115
38116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38117         LDKTxCreationKeys this_ptr_conv;
38118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38119         this_ptr_conv.is_owned = false;
38120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38121         LDKPublicKey val_ref;
38122         CHECK((*env)->GetArrayLength(env, val) == 33);
38123         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38124         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
38125 }
38126
38127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38128         LDKTxCreationKeys this_ptr_conv;
38129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38130         this_ptr_conv.is_owned = false;
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38132         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38133         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
38134         return ret_arr;
38135 }
38136
38137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38138         LDKTxCreationKeys this_ptr_conv;
38139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38140         this_ptr_conv.is_owned = false;
38141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38142         LDKPublicKey val_ref;
38143         CHECK((*env)->GetArrayLength(env, val) == 33);
38144         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38145         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
38146 }
38147
38148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38149         LDKTxCreationKeys this_ptr_conv;
38150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38151         this_ptr_conv.is_owned = false;
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38153         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38154         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
38155         return ret_arr;
38156 }
38157
38158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38159         LDKTxCreationKeys this_ptr_conv;
38160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38161         this_ptr_conv.is_owned = false;
38162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38163         LDKPublicKey val_ref;
38164         CHECK((*env)->GetArrayLength(env, val) == 33);
38165         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38166         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
38167 }
38168
38169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38170         LDKTxCreationKeys this_ptr_conv;
38171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38172         this_ptr_conv.is_owned = false;
38173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38174         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
38176         return ret_arr;
38177 }
38178
38179 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) {
38180         LDKTxCreationKeys this_ptr_conv;
38181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38182         this_ptr_conv.is_owned = false;
38183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38184         LDKPublicKey val_ref;
38185         CHECK((*env)->GetArrayLength(env, val) == 33);
38186         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38187         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
38188 }
38189
38190 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) {
38191         LDKPublicKey per_commitment_point_arg_ref;
38192         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
38193         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
38194         LDKPublicKey revocation_key_arg_ref;
38195         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
38196         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
38197         LDKPublicKey broadcaster_htlc_key_arg_ref;
38198         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
38199         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
38200         LDKPublicKey countersignatory_htlc_key_arg_ref;
38201         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
38202         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
38203         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
38204         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
38205         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
38206         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);
38207         int64_t ret_ref = 0;
38208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38211         ret_ref = (uintptr_t)ret_var.inner;
38212         if (ret_var.is_owned) {
38213                 ret_ref |= 1;
38214         }
38215         return ret_ref;
38216 }
38217
38218 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
38219         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
38220 int64_t ret_ref = 0;
38221 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38222 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38223 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38224 ret_ref = (uintptr_t)ret_var.inner;
38225 if (ret_var.is_owned) {
38226         ret_ref |= 1;
38227 }
38228         return ret_ref;
38229 }
38230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38231         LDKTxCreationKeys arg_conv;
38232         arg_conv.inner = (void*)(arg & (~1));
38233         arg_conv.is_owned = false;
38234         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38235         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
38236         return ret_conv;
38237 }
38238
38239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38240         LDKTxCreationKeys orig_conv;
38241         orig_conv.inner = (void*)(orig & (~1));
38242         orig_conv.is_owned = false;
38243         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38244         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
38245         int64_t ret_ref = 0;
38246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38249         ret_ref = (uintptr_t)ret_var.inner;
38250         if (ret_var.is_owned) {
38251                 ret_ref |= 1;
38252         }
38253         return ret_ref;
38254 }
38255
38256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38257         LDKTxCreationKeys obj_conv;
38258         obj_conv.inner = (void*)(obj & (~1));
38259         obj_conv.is_owned = false;
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38261         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
38262         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38263         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38264         CVec_u8Z_free(ret_var);
38265         return ret_arr;
38266 }
38267
38268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38269         LDKu8slice ser_ref;
38270         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38271         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38272         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
38273         *ret_conv = TxCreationKeys_read(ser_ref);
38274         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38275         return (int64_t)ret_conv;
38276 }
38277
38278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38279         LDKChannelPublicKeys this_obj_conv;
38280         this_obj_conv.inner = (void*)(this_obj & (~1));
38281         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38283         ChannelPublicKeys_free(this_obj_conv);
38284 }
38285
38286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
38287         LDKChannelPublicKeys this_ptr_conv;
38288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38289         this_ptr_conv.is_owned = false;
38290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38291         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
38293         return ret_arr;
38294 }
38295
38296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38297         LDKChannelPublicKeys this_ptr_conv;
38298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38299         this_ptr_conv.is_owned = false;
38300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38301         LDKPublicKey val_ref;
38302         CHECK((*env)->GetArrayLength(env, val) == 33);
38303         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38304         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
38305 }
38306
38307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38308         LDKChannelPublicKeys this_ptr_conv;
38309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38310         this_ptr_conv.is_owned = false;
38311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38312         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
38314         return ret_arr;
38315 }
38316
38317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38318         LDKChannelPublicKeys this_ptr_conv;
38319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38320         this_ptr_conv.is_owned = false;
38321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38322         LDKPublicKey val_ref;
38323         CHECK((*env)->GetArrayLength(env, val) == 33);
38324         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38325         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
38326 }
38327
38328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38329         LDKChannelPublicKeys this_ptr_conv;
38330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38331         this_ptr_conv.is_owned = false;
38332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38333         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38334         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
38335         return ret_arr;
38336 }
38337
38338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38339         LDKChannelPublicKeys this_ptr_conv;
38340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38341         this_ptr_conv.is_owned = false;
38342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38343         LDKPublicKey val_ref;
38344         CHECK((*env)->GetArrayLength(env, val) == 33);
38345         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38346         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
38347 }
38348
38349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38350         LDKChannelPublicKeys this_ptr_conv;
38351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38352         this_ptr_conv.is_owned = false;
38353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38354         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38355         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
38356         return ret_arr;
38357 }
38358
38359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38360         LDKChannelPublicKeys this_ptr_conv;
38361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38362         this_ptr_conv.is_owned = false;
38363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38364         LDKPublicKey val_ref;
38365         CHECK((*env)->GetArrayLength(env, val) == 33);
38366         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38367         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38368 }
38369
38370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38371         LDKChannelPublicKeys this_ptr_conv;
38372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38373         this_ptr_conv.is_owned = false;
38374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38375         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
38377         return ret_arr;
38378 }
38379
38380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38381         LDKChannelPublicKeys this_ptr_conv;
38382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38383         this_ptr_conv.is_owned = false;
38384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38385         LDKPublicKey val_ref;
38386         CHECK((*env)->GetArrayLength(env, val) == 33);
38387         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38388         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
38389 }
38390
38391 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) {
38392         LDKPublicKey funding_pubkey_arg_ref;
38393         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
38394         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
38395         LDKPublicKey revocation_basepoint_arg_ref;
38396         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
38397         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
38398         LDKPublicKey payment_point_arg_ref;
38399         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
38400         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
38401         LDKPublicKey delayed_payment_basepoint_arg_ref;
38402         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
38403         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
38404         LDKPublicKey htlc_basepoint_arg_ref;
38405         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
38406         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
38407         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);
38408         int64_t ret_ref = 0;
38409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38412         ret_ref = (uintptr_t)ret_var.inner;
38413         if (ret_var.is_owned) {
38414                 ret_ref |= 1;
38415         }
38416         return ret_ref;
38417 }
38418
38419 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
38420         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
38421 int64_t ret_ref = 0;
38422 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38423 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38424 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38425 ret_ref = (uintptr_t)ret_var.inner;
38426 if (ret_var.is_owned) {
38427         ret_ref |= 1;
38428 }
38429         return ret_ref;
38430 }
38431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38432         LDKChannelPublicKeys arg_conv;
38433         arg_conv.inner = (void*)(arg & (~1));
38434         arg_conv.is_owned = false;
38435         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38436         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
38437         return ret_conv;
38438 }
38439
38440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38441         LDKChannelPublicKeys orig_conv;
38442         orig_conv.inner = (void*)(orig & (~1));
38443         orig_conv.is_owned = false;
38444         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38445         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
38446         int64_t ret_ref = 0;
38447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38450         ret_ref = (uintptr_t)ret_var.inner;
38451         if (ret_var.is_owned) {
38452                 ret_ref |= 1;
38453         }
38454         return ret_ref;
38455 }
38456
38457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38458         LDKChannelPublicKeys obj_conv;
38459         obj_conv.inner = (void*)(obj & (~1));
38460         obj_conv.is_owned = false;
38461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38462         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
38463         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38464         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38465         CVec_u8Z_free(ret_var);
38466         return ret_arr;
38467 }
38468
38469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38470         LDKu8slice ser_ref;
38471         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38472         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38473         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
38474         *ret_conv = ChannelPublicKeys_read(ser_ref);
38475         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38476         return (int64_t)ret_conv;
38477 }
38478
38479 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) {
38480         LDKPublicKey per_commitment_point_ref;
38481         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38482         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38483         LDKPublicKey broadcaster_delayed_payment_base_ref;
38484         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
38485         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
38486         LDKPublicKey broadcaster_htlc_base_ref;
38487         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
38488         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
38489         LDKPublicKey countersignatory_revocation_base_ref;
38490         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
38491         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
38492         LDKPublicKey countersignatory_htlc_base_ref;
38493         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
38494         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
38495         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
38496         *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);
38497         return (int64_t)ret_conv;
38498 }
38499
38500 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) {
38501         LDKPublicKey per_commitment_point_ref;
38502         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38503         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38504         LDKChannelPublicKeys broadcaster_keys_conv;
38505         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38506         broadcaster_keys_conv.is_owned = false;
38507         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38508         LDKChannelPublicKeys countersignatory_keys_conv;
38509         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38510         countersignatory_keys_conv.is_owned = false;
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38512         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
38513         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
38514         return (int64_t)ret_conv;
38515 }
38516
38517 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) {
38518         LDKPublicKey revocation_key_ref;
38519         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
38520         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
38521         LDKPublicKey broadcaster_delayed_payment_key_ref;
38522         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
38523         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
38524         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
38525         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38526         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38527         CVec_u8Z_free(ret_var);
38528         return ret_arr;
38529 }
38530
38531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38532         LDKHTLCOutputInCommitment this_obj_conv;
38533         this_obj_conv.inner = (void*)(this_obj & (~1));
38534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38536         HTLCOutputInCommitment_free(this_obj_conv);
38537 }
38538
38539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
38540         LDKHTLCOutputInCommitment this_ptr_conv;
38541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38542         this_ptr_conv.is_owned = false;
38543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38544         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
38545         return ret_conv;
38546 }
38547
38548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38549         LDKHTLCOutputInCommitment this_ptr_conv;
38550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38551         this_ptr_conv.is_owned = false;
38552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38553         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
38554 }
38555
38556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38557         LDKHTLCOutputInCommitment this_ptr_conv;
38558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38559         this_ptr_conv.is_owned = false;
38560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38561         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
38562         return ret_conv;
38563 }
38564
38565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38566         LDKHTLCOutputInCommitment this_ptr_conv;
38567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38568         this_ptr_conv.is_owned = false;
38569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38570         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
38571 }
38572
38573 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
38574         LDKHTLCOutputInCommitment this_ptr_conv;
38575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38576         this_ptr_conv.is_owned = false;
38577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38578         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
38579         return ret_conv;
38580 }
38581
38582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38583         LDKHTLCOutputInCommitment this_ptr_conv;
38584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38585         this_ptr_conv.is_owned = false;
38586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38587         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
38588 }
38589
38590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38591         LDKHTLCOutputInCommitment this_ptr_conv;
38592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38593         this_ptr_conv.is_owned = false;
38594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38595         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38596         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
38597         return ret_arr;
38598 }
38599
38600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38601         LDKHTLCOutputInCommitment this_ptr_conv;
38602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38603         this_ptr_conv.is_owned = false;
38604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38605         LDKThirtyTwoBytes val_ref;
38606         CHECK((*env)->GetArrayLength(env, val) == 32);
38607         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38608         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
38609 }
38610
38611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
38612         LDKHTLCOutputInCommitment this_ptr_conv;
38613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38614         this_ptr_conv.is_owned = false;
38615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38616         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
38617         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
38618         int64_t ret_ref = (uintptr_t)ret_copy;
38619         return ret_ref;
38620 }
38621
38622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38623         LDKHTLCOutputInCommitment this_ptr_conv;
38624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38625         this_ptr_conv.is_owned = false;
38626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38627         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38628         CHECK_ACCESS(val_ptr);
38629         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
38630         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
38631         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
38632 }
38633
38634 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) {
38635         LDKThirtyTwoBytes payment_hash_arg_ref;
38636         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
38637         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
38638         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
38639         CHECK_ACCESS(transaction_output_index_arg_ptr);
38640         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
38641         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
38642         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
38643         int64_t ret_ref = 0;
38644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38647         ret_ref = (uintptr_t)ret_var.inner;
38648         if (ret_var.is_owned) {
38649                 ret_ref |= 1;
38650         }
38651         return ret_ref;
38652 }
38653
38654 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
38655         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
38656 int64_t ret_ref = 0;
38657 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38658 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38659 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38660 ret_ref = (uintptr_t)ret_var.inner;
38661 if (ret_var.is_owned) {
38662         ret_ref |= 1;
38663 }
38664         return ret_ref;
38665 }
38666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38667         LDKHTLCOutputInCommitment arg_conv;
38668         arg_conv.inner = (void*)(arg & (~1));
38669         arg_conv.is_owned = false;
38670         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38671         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
38672         return ret_conv;
38673 }
38674
38675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38676         LDKHTLCOutputInCommitment orig_conv;
38677         orig_conv.inner = (void*)(orig & (~1));
38678         orig_conv.is_owned = false;
38679         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38680         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
38681         int64_t ret_ref = 0;
38682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38685         ret_ref = (uintptr_t)ret_var.inner;
38686         if (ret_var.is_owned) {
38687                 ret_ref |= 1;
38688         }
38689         return ret_ref;
38690 }
38691
38692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
38693         LDKHTLCOutputInCommitment obj_conv;
38694         obj_conv.inner = (void*)(obj & (~1));
38695         obj_conv.is_owned = false;
38696         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38697         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
38698         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38699         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38700         CVec_u8Z_free(ret_var);
38701         return ret_arr;
38702 }
38703
38704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38705         LDKu8slice ser_ref;
38706         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38707         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38708         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
38709         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
38710         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38711         return (int64_t)ret_conv;
38712 }
38713
38714 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) {
38715         LDKHTLCOutputInCommitment htlc_conv;
38716         htlc_conv.inner = (void*)(htlc & (~1));
38717         htlc_conv.is_owned = false;
38718         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
38719         LDKTxCreationKeys keys_conv;
38720         keys_conv.inner = (void*)(keys & (~1));
38721         keys_conv.is_owned = false;
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
38723         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
38724         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38725         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38726         CVec_u8Z_free(ret_var);
38727         return ret_arr;
38728 }
38729
38730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
38731         LDKPublicKey broadcaster_ref;
38732         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
38733         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
38734         LDKPublicKey countersignatory_ref;
38735         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
38736         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
38737         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
38738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38740         CVec_u8Z_free(ret_var);
38741         return ret_arr;
38742 }
38743
38744 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) {
38745         unsigned char commitment_txid_arr[32];
38746         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
38747         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
38748         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
38749         LDKHTLCOutputInCommitment htlc_conv;
38750         htlc_conv.inner = (void*)(htlc & (~1));
38751         htlc_conv.is_owned = false;
38752         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
38753         LDKPublicKey broadcaster_delayed_payment_key_ref;
38754         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
38755         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
38756         LDKPublicKey revocation_key_ref;
38757         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
38758         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
38759         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);
38760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38762         Transaction_free(ret_var);
38763         return ret_arr;
38764 }
38765
38766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
38767         LDKPublicKey funding_pubkey_ref;
38768         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
38769         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
38770         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
38771         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38772         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38773         CVec_u8Z_free(ret_var);
38774         return ret_arr;
38775 }
38776
38777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38778         LDKChannelTransactionParameters this_obj_conv;
38779         this_obj_conv.inner = (void*)(this_obj & (~1));
38780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38782         ChannelTransactionParameters_free(this_obj_conv);
38783 }
38784
38785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
38786         LDKChannelTransactionParameters this_ptr_conv;
38787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38788         this_ptr_conv.is_owned = false;
38789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38790         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
38791         int64_t ret_ref = 0;
38792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38795         ret_ref = (uintptr_t)ret_var.inner;
38796         if (ret_var.is_owned) {
38797                 ret_ref |= 1;
38798         }
38799         return ret_ref;
38800 }
38801
38802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38803         LDKChannelTransactionParameters this_ptr_conv;
38804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38805         this_ptr_conv.is_owned = false;
38806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38807         LDKChannelPublicKeys val_conv;
38808         val_conv.inner = (void*)(val & (~1));
38809         val_conv.is_owned = (val & 1) || (val == 0);
38810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38811         val_conv = ChannelPublicKeys_clone(&val_conv);
38812         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
38813 }
38814
38815 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
38816         LDKChannelTransactionParameters this_ptr_conv;
38817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38818         this_ptr_conv.is_owned = false;
38819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38820         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
38821         return ret_conv;
38822 }
38823
38824 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) {
38825         LDKChannelTransactionParameters this_ptr_conv;
38826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38827         this_ptr_conv.is_owned = false;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38829         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
38830 }
38831
38832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
38833         LDKChannelTransactionParameters this_ptr_conv;
38834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38835         this_ptr_conv.is_owned = false;
38836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38837         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
38838         return ret_conv;
38839 }
38840
38841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38842         LDKChannelTransactionParameters this_ptr_conv;
38843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38844         this_ptr_conv.is_owned = false;
38845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38846         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
38847 }
38848
38849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
38850         LDKChannelTransactionParameters this_ptr_conv;
38851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38852         this_ptr_conv.is_owned = false;
38853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38854         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
38855         int64_t ret_ref = 0;
38856         if ((uintptr_t)ret_var.inner > 4096) {
38857                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38858                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38860                 ret_ref = (uintptr_t)ret_var.inner;
38861                 if (ret_var.is_owned) {
38862                         ret_ref |= 1;
38863                 }
38864         }
38865         return ret_ref;
38866 }
38867
38868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38869         LDKChannelTransactionParameters this_ptr_conv;
38870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38871         this_ptr_conv.is_owned = false;
38872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38873         LDKCounterpartyChannelTransactionParameters val_conv;
38874         val_conv.inner = (void*)(val & (~1));
38875         val_conv.is_owned = (val & 1) || (val == 0);
38876         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38877         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
38878         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
38879 }
38880
38881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38882         LDKChannelTransactionParameters this_ptr_conv;
38883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38884         this_ptr_conv.is_owned = false;
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38886         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
38887         int64_t ret_ref = 0;
38888         if ((uintptr_t)ret_var.inner > 4096) {
38889                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38890                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38892                 ret_ref = (uintptr_t)ret_var.inner;
38893                 if (ret_var.is_owned) {
38894                         ret_ref |= 1;
38895                 }
38896         }
38897         return ret_ref;
38898 }
38899
38900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38901         LDKChannelTransactionParameters this_ptr_conv;
38902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38903         this_ptr_conv.is_owned = false;
38904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38905         LDKOutPoint val_conv;
38906         val_conv.inner = (void*)(val & (~1));
38907         val_conv.is_owned = (val & 1) || (val == 0);
38908         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38909         val_conv = OutPoint_clone(&val_conv);
38910         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
38911 }
38912
38913 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
38914         LDKChannelTransactionParameters this_ptr_conv;
38915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38916         this_ptr_conv.is_owned = false;
38917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38918         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
38919         return ret_conv;
38920 }
38921
38922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
38923         LDKChannelTransactionParameters this_ptr_conv;
38924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38925         this_ptr_conv.is_owned = false;
38926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38927         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
38928         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
38929 }
38930
38931 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) {
38932         LDKChannelPublicKeys holder_pubkeys_arg_conv;
38933         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
38934         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
38935         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
38936         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
38937         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
38938         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
38939         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
38940         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
38941         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
38942         LDKOutPoint funding_outpoint_arg_conv;
38943         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
38944         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
38945         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
38946         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
38947         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
38948         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);
38949         int64_t ret_ref = 0;
38950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38953         ret_ref = (uintptr_t)ret_var.inner;
38954         if (ret_var.is_owned) {
38955                 ret_ref |= 1;
38956         }
38957         return ret_ref;
38958 }
38959
38960 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
38961         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
38962 int64_t ret_ref = 0;
38963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38966 ret_ref = (uintptr_t)ret_var.inner;
38967 if (ret_var.is_owned) {
38968         ret_ref |= 1;
38969 }
38970         return ret_ref;
38971 }
38972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38973         LDKChannelTransactionParameters arg_conv;
38974         arg_conv.inner = (void*)(arg & (~1));
38975         arg_conv.is_owned = false;
38976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38977         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
38978         return ret_conv;
38979 }
38980
38981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38982         LDKChannelTransactionParameters orig_conv;
38983         orig_conv.inner = (void*)(orig & (~1));
38984         orig_conv.is_owned = false;
38985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38986         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
38987         int64_t ret_ref = 0;
38988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38991         ret_ref = (uintptr_t)ret_var.inner;
38992         if (ret_var.is_owned) {
38993                 ret_ref |= 1;
38994         }
38995         return ret_ref;
38996 }
38997
38998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38999         LDKCounterpartyChannelTransactionParameters this_obj_conv;
39000         this_obj_conv.inner = (void*)(this_obj & (~1));
39001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39003         CounterpartyChannelTransactionParameters_free(this_obj_conv);
39004 }
39005
39006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39007         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39009         this_ptr_conv.is_owned = false;
39010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39011         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
39012         int64_t ret_ref = 0;
39013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39016         ret_ref = (uintptr_t)ret_var.inner;
39017         if (ret_var.is_owned) {
39018                 ret_ref |= 1;
39019         }
39020         return ret_ref;
39021 }
39022
39023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39024         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39026         this_ptr_conv.is_owned = false;
39027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39028         LDKChannelPublicKeys val_conv;
39029         val_conv.inner = (void*)(val & (~1));
39030         val_conv.is_owned = (val & 1) || (val == 0);
39031         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39032         val_conv = ChannelPublicKeys_clone(&val_conv);
39033         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
39034 }
39035
39036 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39037         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39039         this_ptr_conv.is_owned = false;
39040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39041         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
39042         return ret_conv;
39043 }
39044
39045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39046         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39048         this_ptr_conv.is_owned = false;
39049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39050         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
39051 }
39052
39053 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) {
39054         LDKChannelPublicKeys pubkeys_arg_conv;
39055         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
39056         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
39057         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
39058         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
39059         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
39060         int64_t ret_ref = 0;
39061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39064         ret_ref = (uintptr_t)ret_var.inner;
39065         if (ret_var.is_owned) {
39066                 ret_ref |= 1;
39067         }
39068         return ret_ref;
39069 }
39070
39071 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
39072         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
39073 int64_t ret_ref = 0;
39074 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39075 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39076 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39077 ret_ref = (uintptr_t)ret_var.inner;
39078 if (ret_var.is_owned) {
39079         ret_ref |= 1;
39080 }
39081         return ret_ref;
39082 }
39083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39084         LDKCounterpartyChannelTransactionParameters arg_conv;
39085         arg_conv.inner = (void*)(arg & (~1));
39086         arg_conv.is_owned = false;
39087         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39088         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
39089         return ret_conv;
39090 }
39091
39092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39093         LDKCounterpartyChannelTransactionParameters orig_conv;
39094         orig_conv.inner = (void*)(orig & (~1));
39095         orig_conv.is_owned = false;
39096         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39097         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
39098         int64_t ret_ref = 0;
39099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39102         ret_ref = (uintptr_t)ret_var.inner;
39103         if (ret_var.is_owned) {
39104                 ret_ref |= 1;
39105         }
39106         return ret_ref;
39107 }
39108
39109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
39110         LDKChannelTransactionParameters this_arg_conv;
39111         this_arg_conv.inner = (void*)(this_arg & (~1));
39112         this_arg_conv.is_owned = false;
39113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39114         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
39115         return ret_conv;
39116 }
39117
39118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39119         LDKChannelTransactionParameters this_arg_conv;
39120         this_arg_conv.inner = (void*)(this_arg & (~1));
39121         this_arg_conv.is_owned = false;
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39123         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
39124         int64_t ret_ref = 0;
39125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39128         ret_ref = (uintptr_t)ret_var.inner;
39129         if (ret_var.is_owned) {
39130                 ret_ref |= 1;
39131         }
39132         return ret_ref;
39133 }
39134
39135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39136         LDKChannelTransactionParameters this_arg_conv;
39137         this_arg_conv.inner = (void*)(this_arg & (~1));
39138         this_arg_conv.is_owned = false;
39139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39140         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
39141         int64_t ret_ref = 0;
39142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39145         ret_ref = (uintptr_t)ret_var.inner;
39146         if (ret_var.is_owned) {
39147                 ret_ref |= 1;
39148         }
39149         return ret_ref;
39150 }
39151
39152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39153         LDKCounterpartyChannelTransactionParameters obj_conv;
39154         obj_conv.inner = (void*)(obj & (~1));
39155         obj_conv.is_owned = false;
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39157         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
39158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39160         CVec_u8Z_free(ret_var);
39161         return ret_arr;
39162 }
39163
39164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39165         LDKu8slice ser_ref;
39166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39168         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
39169         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
39170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39171         return (int64_t)ret_conv;
39172 }
39173
39174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39175         LDKChannelTransactionParameters obj_conv;
39176         obj_conv.inner = (void*)(obj & (~1));
39177         obj_conv.is_owned = false;
39178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39179         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
39180         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39181         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39182         CVec_u8Z_free(ret_var);
39183         return ret_arr;
39184 }
39185
39186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39187         LDKu8slice ser_ref;
39188         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39189         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39190         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
39191         *ret_conv = ChannelTransactionParameters_read(ser_ref);
39192         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39193         return (int64_t)ret_conv;
39194 }
39195
39196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39197         LDKDirectedChannelTransactionParameters this_obj_conv;
39198         this_obj_conv.inner = (void*)(this_obj & (~1));
39199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39201         DirectedChannelTransactionParameters_free(this_obj_conv);
39202 }
39203
39204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39205         LDKDirectedChannelTransactionParameters this_arg_conv;
39206         this_arg_conv.inner = (void*)(this_arg & (~1));
39207         this_arg_conv.is_owned = false;
39208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39209         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
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_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39222         LDKDirectedChannelTransactionParameters this_arg_conv;
39223         this_arg_conv.inner = (void*)(this_arg & (~1));
39224         this_arg_conv.is_owned = false;
39225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39226         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
39227         int64_t ret_ref = 0;
39228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39231         ret_ref = (uintptr_t)ret_var.inner;
39232         if (ret_var.is_owned) {
39233                 ret_ref |= 1;
39234         }
39235         return ret_ref;
39236 }
39237
39238 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
39239         LDKDirectedChannelTransactionParameters this_arg_conv;
39240         this_arg_conv.inner = (void*)(this_arg & (~1));
39241         this_arg_conv.is_owned = false;
39242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39243         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
39244         return ret_conv;
39245 }
39246
39247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
39248         LDKDirectedChannelTransactionParameters this_arg_conv;
39249         this_arg_conv.inner = (void*)(this_arg & (~1));
39250         this_arg_conv.is_owned = false;
39251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39252         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
39253         return ret_conv;
39254 }
39255
39256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
39257         LDKDirectedChannelTransactionParameters this_arg_conv;
39258         this_arg_conv.inner = (void*)(this_arg & (~1));
39259         this_arg_conv.is_owned = false;
39260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39261         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
39262         int64_t ret_ref = 0;
39263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39266         ret_ref = (uintptr_t)ret_var.inner;
39267         if (ret_var.is_owned) {
39268                 ret_ref |= 1;
39269         }
39270         return ret_ref;
39271 }
39272
39273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
39274         LDKDirectedChannelTransactionParameters this_arg_conv;
39275         this_arg_conv.inner = (void*)(this_arg & (~1));
39276         this_arg_conv.is_owned = false;
39277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39278         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
39279         return ret_conv;
39280 }
39281
39282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39283         LDKHolderCommitmentTransaction this_obj_conv;
39284         this_obj_conv.inner = (void*)(this_obj & (~1));
39285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39287         HolderCommitmentTransaction_free(this_obj_conv);
39288 }
39289
39290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
39291         LDKHolderCommitmentTransaction this_ptr_conv;
39292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39293         this_ptr_conv.is_owned = false;
39294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39295         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39296         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
39297         return ret_arr;
39298 }
39299
39300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39301         LDKHolderCommitmentTransaction this_ptr_conv;
39302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39303         this_ptr_conv.is_owned = false;
39304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39305         LDKSignature val_ref;
39306         CHECK((*env)->GetArrayLength(env, val) == 64);
39307         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39308         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
39309 }
39310
39311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
39312         LDKHolderCommitmentTransaction this_ptr_conv;
39313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39314         this_ptr_conv.is_owned = false;
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39316         LDKCVec_SignatureZ val_constr;
39317         val_constr.datalen = (*env)->GetArrayLength(env, val);
39318         if (val_constr.datalen > 0)
39319                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
39320         else
39321                 val_constr.data = NULL;
39322         for (size_t i = 0; i < val_constr.datalen; i++) {
39323                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
39324                 LDKSignature val_conv_8_ref;
39325                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
39326                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
39327                 val_constr.data[i] = val_conv_8_ref;
39328         }
39329         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
39330 }
39331
39332 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
39333         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
39334 int64_t ret_ref = 0;
39335 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39336 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39337 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39338 ret_ref = (uintptr_t)ret_var.inner;
39339 if (ret_var.is_owned) {
39340         ret_ref |= 1;
39341 }
39342         return ret_ref;
39343 }
39344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39345         LDKHolderCommitmentTransaction arg_conv;
39346         arg_conv.inner = (void*)(arg & (~1));
39347         arg_conv.is_owned = false;
39348         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39349         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
39350         return ret_conv;
39351 }
39352
39353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39354         LDKHolderCommitmentTransaction orig_conv;
39355         orig_conv.inner = (void*)(orig & (~1));
39356         orig_conv.is_owned = false;
39357         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39358         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
39359         int64_t ret_ref = 0;
39360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39363         ret_ref = (uintptr_t)ret_var.inner;
39364         if (ret_var.is_owned) {
39365                 ret_ref |= 1;
39366         }
39367         return ret_ref;
39368 }
39369
39370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39371         LDKHolderCommitmentTransaction obj_conv;
39372         obj_conv.inner = (void*)(obj & (~1));
39373         obj_conv.is_owned = false;
39374         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39375         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
39376         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39377         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39378         CVec_u8Z_free(ret_var);
39379         return ret_arr;
39380 }
39381
39382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39383         LDKu8slice ser_ref;
39384         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39385         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39386         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
39387         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
39388         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39389         return (int64_t)ret_conv;
39390 }
39391
39392 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) {
39393         LDKCommitmentTransaction commitment_tx_conv;
39394         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
39395         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
39396         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
39397         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
39398         LDKSignature counterparty_sig_ref;
39399         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
39400         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
39401         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
39402         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
39403         if (counterparty_htlc_sigs_constr.datalen > 0)
39404                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
39405         else
39406                 counterparty_htlc_sigs_constr.data = NULL;
39407         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
39408                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
39409                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
39410                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
39411                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
39412                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
39413         }
39414         LDKPublicKey holder_funding_key_ref;
39415         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
39416         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
39417         LDKPublicKey counterparty_funding_key_ref;
39418         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
39419         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
39420         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
39421         int64_t ret_ref = 0;
39422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39425         ret_ref = (uintptr_t)ret_var.inner;
39426         if (ret_var.is_owned) {
39427                 ret_ref |= 1;
39428         }
39429         return ret_ref;
39430 }
39431
39432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39433         LDKBuiltCommitmentTransaction this_obj_conv;
39434         this_obj_conv.inner = (void*)(this_obj & (~1));
39435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39437         BuiltCommitmentTransaction_free(this_obj_conv);
39438 }
39439
39440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
39441         LDKBuiltCommitmentTransaction this_ptr_conv;
39442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39443         this_ptr_conv.is_owned = false;
39444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39445         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
39446         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39447         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39448         Transaction_free(ret_var);
39449         return ret_arr;
39450 }
39451
39452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39453         LDKBuiltCommitmentTransaction this_ptr_conv;
39454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39455         this_ptr_conv.is_owned = false;
39456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39457         LDKTransaction val_ref;
39458         val_ref.datalen = (*env)->GetArrayLength(env, val);
39459         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
39460         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39461         val_ref.data_is_owned = true;
39462         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
39463 }
39464
39465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
39466         LDKBuiltCommitmentTransaction this_ptr_conv;
39467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39468         this_ptr_conv.is_owned = false;
39469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39470         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
39472         return ret_arr;
39473 }
39474
39475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39476         LDKBuiltCommitmentTransaction this_ptr_conv;
39477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39478         this_ptr_conv.is_owned = false;
39479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39480         LDKThirtyTwoBytes val_ref;
39481         CHECK((*env)->GetArrayLength(env, val) == 32);
39482         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39483         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
39484 }
39485
39486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
39487         LDKTransaction transaction_arg_ref;
39488         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
39489         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
39490         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
39491         transaction_arg_ref.data_is_owned = true;
39492         LDKThirtyTwoBytes txid_arg_ref;
39493         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
39494         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
39495         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
39496         int64_t ret_ref = 0;
39497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39500         ret_ref = (uintptr_t)ret_var.inner;
39501         if (ret_var.is_owned) {
39502                 ret_ref |= 1;
39503         }
39504         return ret_ref;
39505 }
39506
39507 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
39508         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39520         LDKBuiltCommitmentTransaction arg_conv;
39521         arg_conv.inner = (void*)(arg & (~1));
39522         arg_conv.is_owned = false;
39523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39524         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
39525         return ret_conv;
39526 }
39527
39528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39529         LDKBuiltCommitmentTransaction orig_conv;
39530         orig_conv.inner = (void*)(orig & (~1));
39531         orig_conv.is_owned = false;
39532         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39533         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
39534         int64_t ret_ref = 0;
39535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39538         ret_ref = (uintptr_t)ret_var.inner;
39539         if (ret_var.is_owned) {
39540                 ret_ref |= 1;
39541         }
39542         return ret_ref;
39543 }
39544
39545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39546         LDKBuiltCommitmentTransaction obj_conv;
39547         obj_conv.inner = (void*)(obj & (~1));
39548         obj_conv.is_owned = false;
39549         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39550         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
39551         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39552         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39553         CVec_u8Z_free(ret_var);
39554         return ret_arr;
39555 }
39556
39557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39558         LDKu8slice ser_ref;
39559         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39560         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39561         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
39562         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
39563         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39564         return (int64_t)ret_conv;
39565 }
39566
39567 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) {
39568         LDKBuiltCommitmentTransaction this_arg_conv;
39569         this_arg_conv.inner = (void*)(this_arg & (~1));
39570         this_arg_conv.is_owned = false;
39571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39572         LDKu8slice funding_redeemscript_ref;
39573         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39574         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39575         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
39577         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39578         return ret_arr;
39579 }
39580
39581 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) {
39582         LDKBuiltCommitmentTransaction this_arg_conv;
39583         this_arg_conv.inner = (void*)(this_arg & (~1));
39584         this_arg_conv.is_owned = false;
39585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39586         unsigned char funding_key_arr[32];
39587         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
39588         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
39589         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
39590         LDKu8slice funding_redeemscript_ref;
39591         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39592         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39593         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
39595         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39596         return ret_arr;
39597 }
39598
39599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39600         LDKClosingTransaction this_obj_conv;
39601         this_obj_conv.inner = (void*)(this_obj & (~1));
39602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39604         ClosingTransaction_free(this_obj_conv);
39605 }
39606
39607 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
39608         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
39609 int64_t ret_ref = 0;
39610 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39611 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39612 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39613 ret_ref = (uintptr_t)ret_var.inner;
39614 if (ret_var.is_owned) {
39615         ret_ref |= 1;
39616 }
39617         return ret_ref;
39618 }
39619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39620         LDKClosingTransaction arg_conv;
39621         arg_conv.inner = (void*)(arg & (~1));
39622         arg_conv.is_owned = false;
39623         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39624         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
39625         return ret_conv;
39626 }
39627
39628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39629         LDKClosingTransaction orig_conv;
39630         orig_conv.inner = (void*)(orig & (~1));
39631         orig_conv.is_owned = false;
39632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39633         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
39634         int64_t ret_ref = 0;
39635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39638         ret_ref = (uintptr_t)ret_var.inner;
39639         if (ret_var.is_owned) {
39640                 ret_ref |= 1;
39641         }
39642         return ret_ref;
39643 }
39644
39645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
39646         LDKClosingTransaction o_conv;
39647         o_conv.inner = (void*)(o & (~1));
39648         o_conv.is_owned = false;
39649         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39650         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
39651         return ret_conv;
39652 }
39653
39654 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) {
39655         LDKCVec_u8Z to_holder_script_ref;
39656         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
39657         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
39658         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
39659         LDKCVec_u8Z to_counterparty_script_ref;
39660         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
39661         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
39662         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
39663         LDKOutPoint funding_outpoint_conv;
39664         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
39665         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
39666         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39667         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39668         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
39669         int64_t ret_ref = 0;
39670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39673         ret_ref = (uintptr_t)ret_var.inner;
39674         if (ret_var.is_owned) {
39675                 ret_ref |= 1;
39676         }
39677         return ret_ref;
39678 }
39679
39680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39681         LDKClosingTransaction this_arg_conv;
39682         this_arg_conv.inner = (void*)(this_arg & (~1));
39683         this_arg_conv.is_owned = false;
39684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39685         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
39686         int64_t ret_ref = 0;
39687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39690         ret_ref = (uintptr_t)ret_var.inner;
39691         if (ret_var.is_owned) {
39692                 ret_ref |= 1;
39693         }
39694         return ret_ref;
39695 }
39696
39697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
39698         LDKClosingTransaction this_arg_conv;
39699         this_arg_conv.inner = (void*)(this_arg & (~1));
39700         this_arg_conv.is_owned = false;
39701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39702         LDKOutPoint funding_outpoint_conv;
39703         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
39704         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
39705         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39706         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39707         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
39708         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
39709         return (int64_t)ret_conv;
39710 }
39711
39712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39713         LDKClosingTransaction this_arg_conv;
39714         this_arg_conv.inner = (void*)(this_arg & (~1));
39715         this_arg_conv.is_owned = false;
39716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39717         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
39718         return ret_conv;
39719 }
39720
39721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39722         LDKClosingTransaction this_arg_conv;
39723         this_arg_conv.inner = (void*)(this_arg & (~1));
39724         this_arg_conv.is_owned = false;
39725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39726         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
39727         return ret_conv;
39728 }
39729
39730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39731         LDKClosingTransaction this_arg_conv;
39732         this_arg_conv.inner = (void*)(this_arg & (~1));
39733         this_arg_conv.is_owned = false;
39734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39735         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
39736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39738         return ret_arr;
39739 }
39740
39741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39742         LDKClosingTransaction this_arg_conv;
39743         this_arg_conv.inner = (void*)(this_arg & (~1));
39744         this_arg_conv.is_owned = false;
39745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39746         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
39747         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39748         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39749         return ret_arr;
39750 }
39751
39752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39753         LDKTrustedClosingTransaction this_obj_conv;
39754         this_obj_conv.inner = (void*)(this_obj & (~1));
39755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39757         TrustedClosingTransaction_free(this_obj_conv);
39758 }
39759
39760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39761         LDKTrustedClosingTransaction this_arg_conv;
39762         this_arg_conv.inner = (void*)(this_arg & (~1));
39763         this_arg_conv.is_owned = false;
39764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39765         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
39766         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39767         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39768         Transaction_free(ret_var);
39769         return ret_arr;
39770 }
39771
39772 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) {
39773         LDKTrustedClosingTransaction this_arg_conv;
39774         this_arg_conv.inner = (void*)(this_arg & (~1));
39775         this_arg_conv.is_owned = false;
39776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39777         LDKu8slice funding_redeemscript_ref;
39778         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39779         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39780         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
39782         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39783         return ret_arr;
39784 }
39785
39786 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) {
39787         LDKTrustedClosingTransaction this_arg_conv;
39788         this_arg_conv.inner = (void*)(this_arg & (~1));
39789         this_arg_conv.is_owned = false;
39790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39791         unsigned char funding_key_arr[32];
39792         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
39793         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
39794         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
39795         LDKu8slice funding_redeemscript_ref;
39796         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39797         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39798         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
39800         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39801         return ret_arr;
39802 }
39803
39804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39805         LDKCommitmentTransaction this_obj_conv;
39806         this_obj_conv.inner = (void*)(this_obj & (~1));
39807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39809         CommitmentTransaction_free(this_obj_conv);
39810 }
39811
39812 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
39813         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
39814 int64_t ret_ref = 0;
39815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39818 ret_ref = (uintptr_t)ret_var.inner;
39819 if (ret_var.is_owned) {
39820         ret_ref |= 1;
39821 }
39822         return ret_ref;
39823 }
39824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39825         LDKCommitmentTransaction arg_conv;
39826         arg_conv.inner = (void*)(arg & (~1));
39827         arg_conv.is_owned = false;
39828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39829         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
39830         return ret_conv;
39831 }
39832
39833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39834         LDKCommitmentTransaction orig_conv;
39835         orig_conv.inner = (void*)(orig & (~1));
39836         orig_conv.is_owned = false;
39837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39838         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
39839         int64_t ret_ref = 0;
39840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39843         ret_ref = (uintptr_t)ret_var.inner;
39844         if (ret_var.is_owned) {
39845                 ret_ref |= 1;
39846         }
39847         return ret_ref;
39848 }
39849
39850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39851         LDKCommitmentTransaction obj_conv;
39852         obj_conv.inner = (void*)(obj & (~1));
39853         obj_conv.is_owned = false;
39854         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39855         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
39856         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39857         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39858         CVec_u8Z_free(ret_var);
39859         return ret_arr;
39860 }
39861
39862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39863         LDKu8slice ser_ref;
39864         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39865         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39866         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
39867         *ret_conv = CommitmentTransaction_read(ser_ref);
39868         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39869         return (int64_t)ret_conv;
39870 }
39871
39872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
39873         LDKCommitmentTransaction this_arg_conv;
39874         this_arg_conv.inner = (void*)(this_arg & (~1));
39875         this_arg_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39877         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
39878         return ret_conv;
39879 }
39880
39881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39882         LDKCommitmentTransaction this_arg_conv;
39883         this_arg_conv.inner = (void*)(this_arg & (~1));
39884         this_arg_conv.is_owned = false;
39885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39886         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
39887         return ret_conv;
39888 }
39889
39890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39891         LDKCommitmentTransaction this_arg_conv;
39892         this_arg_conv.inner = (void*)(this_arg & (~1));
39893         this_arg_conv.is_owned = false;
39894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39895         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
39896         return ret_conv;
39897 }
39898
39899 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
39900         LDKCommitmentTransaction this_arg_conv;
39901         this_arg_conv.inner = (void*)(this_arg & (~1));
39902         this_arg_conv.is_owned = false;
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39904         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
39905         return ret_conv;
39906 }
39907
39908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39909         LDKCommitmentTransaction this_arg_conv;
39910         this_arg_conv.inner = (void*)(this_arg & (~1));
39911         this_arg_conv.is_owned = false;
39912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39913         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
39914         int64_t ret_ref = 0;
39915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39918         ret_ref = (uintptr_t)ret_var.inner;
39919         if (ret_var.is_owned) {
39920                 ret_ref |= 1;
39921         }
39922         return ret_ref;
39923 }
39924
39925 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) {
39926         LDKCommitmentTransaction this_arg_conv;
39927         this_arg_conv.inner = (void*)(this_arg & (~1));
39928         this_arg_conv.is_owned = false;
39929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39930         LDKDirectedChannelTransactionParameters channel_parameters_conv;
39931         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
39932         channel_parameters_conv.is_owned = false;
39933         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
39934         LDKChannelPublicKeys broadcaster_keys_conv;
39935         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39936         broadcaster_keys_conv.is_owned = false;
39937         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39938         LDKChannelPublicKeys countersignatory_keys_conv;
39939         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39940         countersignatory_keys_conv.is_owned = false;
39941         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39942         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
39943         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
39944         return (int64_t)ret_conv;
39945 }
39946
39947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39948         LDKTrustedCommitmentTransaction this_obj_conv;
39949         this_obj_conv.inner = (void*)(this_obj & (~1));
39950         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39952         TrustedCommitmentTransaction_free(this_obj_conv);
39953 }
39954
39955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
39956         LDKTrustedCommitmentTransaction this_arg_conv;
39957         this_arg_conv.inner = (void*)(this_arg & (~1));
39958         this_arg_conv.is_owned = false;
39959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39960         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
39962         return ret_arr;
39963 }
39964
39965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39966         LDKTrustedCommitmentTransaction this_arg_conv;
39967         this_arg_conv.inner = (void*)(this_arg & (~1));
39968         this_arg_conv.is_owned = false;
39969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39970         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
39971         int64_t ret_ref = 0;
39972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39975         ret_ref = (uintptr_t)ret_var.inner;
39976         if (ret_var.is_owned) {
39977                 ret_ref |= 1;
39978         }
39979         return ret_ref;
39980 }
39981
39982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
39983         LDKTrustedCommitmentTransaction this_arg_conv;
39984         this_arg_conv.inner = (void*)(this_arg & (~1));
39985         this_arg_conv.is_owned = false;
39986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39987         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
39988         int64_t ret_ref = 0;
39989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39992         ret_ref = (uintptr_t)ret_var.inner;
39993         if (ret_var.is_owned) {
39994                 ret_ref |= 1;
39995         }
39996         return ret_ref;
39997 }
39998
39999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40000         LDKTrustedCommitmentTransaction this_arg_conv;
40001         this_arg_conv.inner = (void*)(this_arg & (~1));
40002         this_arg_conv.is_owned = false;
40003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40004         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
40005         return ret_conv;
40006 }
40007
40008 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) {
40009         LDKTrustedCommitmentTransaction this_arg_conv;
40010         this_arg_conv.inner = (void*)(this_arg & (~1));
40011         this_arg_conv.is_owned = false;
40012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40013         unsigned char htlc_base_key_arr[32];
40014         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
40015         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
40016         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
40017         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40018         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40019         channel_parameters_conv.is_owned = false;
40020         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40021         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
40022         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
40023         return (int64_t)ret_conv;
40024 }
40025
40026 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) {
40027         LDKPublicKey broadcaster_payment_basepoint_ref;
40028         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
40029         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
40030         LDKPublicKey countersignatory_payment_basepoint_ref;
40031         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
40032         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
40033         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
40034         return ret_conv;
40035 }
40036
40037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40038         LDKInitFeatures a_conv;
40039         a_conv.inner = (void*)(a & (~1));
40040         a_conv.is_owned = false;
40041         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40042         LDKInitFeatures b_conv;
40043         b_conv.inner = (void*)(b & (~1));
40044         b_conv.is_owned = false;
40045         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40046         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
40047         return ret_conv;
40048 }
40049
40050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40051         LDKNodeFeatures a_conv;
40052         a_conv.inner = (void*)(a & (~1));
40053         a_conv.is_owned = false;
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40055         LDKNodeFeatures b_conv;
40056         b_conv.inner = (void*)(b & (~1));
40057         b_conv.is_owned = false;
40058         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40059         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
40060         return ret_conv;
40061 }
40062
40063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40064         LDKChannelFeatures a_conv;
40065         a_conv.inner = (void*)(a & (~1));
40066         a_conv.is_owned = false;
40067         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40068         LDKChannelFeatures b_conv;
40069         b_conv.inner = (void*)(b & (~1));
40070         b_conv.is_owned = false;
40071         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40072         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
40073         return ret_conv;
40074 }
40075
40076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40077         LDKInvoiceFeatures a_conv;
40078         a_conv.inner = (void*)(a & (~1));
40079         a_conv.is_owned = false;
40080         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40081         LDKInvoiceFeatures b_conv;
40082         b_conv.inner = (void*)(b & (~1));
40083         b_conv.is_owned = false;
40084         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40085         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
40086         return ret_conv;
40087 }
40088
40089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40090         LDKChannelTypeFeatures a_conv;
40091         a_conv.inner = (void*)(a & (~1));
40092         a_conv.is_owned = false;
40093         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40094         LDKChannelTypeFeatures b_conv;
40095         b_conv.inner = (void*)(b & (~1));
40096         b_conv.is_owned = false;
40097         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40098         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
40099         return ret_conv;
40100 }
40101
40102 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
40103         LDKInitFeatures ret_var = InitFeatures_clone(arg);
40104 int64_t ret_ref = 0;
40105 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40106 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40107 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40108 ret_ref = (uintptr_t)ret_var.inner;
40109 if (ret_var.is_owned) {
40110         ret_ref |= 1;
40111 }
40112         return ret_ref;
40113 }
40114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40115         LDKInitFeatures arg_conv;
40116         arg_conv.inner = (void*)(arg & (~1));
40117         arg_conv.is_owned = false;
40118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40119         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
40120         return ret_conv;
40121 }
40122
40123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40124         LDKInitFeatures orig_conv;
40125         orig_conv.inner = (void*)(orig & (~1));
40126         orig_conv.is_owned = false;
40127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40128         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
40129         int64_t ret_ref = 0;
40130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40133         ret_ref = (uintptr_t)ret_var.inner;
40134         if (ret_var.is_owned) {
40135                 ret_ref |= 1;
40136         }
40137         return ret_ref;
40138 }
40139
40140 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
40141         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
40142 int64_t ret_ref = 0;
40143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40146 ret_ref = (uintptr_t)ret_var.inner;
40147 if (ret_var.is_owned) {
40148         ret_ref |= 1;
40149 }
40150         return ret_ref;
40151 }
40152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40153         LDKNodeFeatures arg_conv;
40154         arg_conv.inner = (void*)(arg & (~1));
40155         arg_conv.is_owned = false;
40156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40157         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
40158         return ret_conv;
40159 }
40160
40161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40162         LDKNodeFeatures orig_conv;
40163         orig_conv.inner = (void*)(orig & (~1));
40164         orig_conv.is_owned = false;
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40166         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
40167         int64_t ret_ref = 0;
40168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40171         ret_ref = (uintptr_t)ret_var.inner;
40172         if (ret_var.is_owned) {
40173                 ret_ref |= 1;
40174         }
40175         return ret_ref;
40176 }
40177
40178 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
40179         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
40180 int64_t ret_ref = 0;
40181 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40182 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40183 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40184 ret_ref = (uintptr_t)ret_var.inner;
40185 if (ret_var.is_owned) {
40186         ret_ref |= 1;
40187 }
40188         return ret_ref;
40189 }
40190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40191         LDKChannelFeatures arg_conv;
40192         arg_conv.inner = (void*)(arg & (~1));
40193         arg_conv.is_owned = false;
40194         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40195         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
40196         return ret_conv;
40197 }
40198
40199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40200         LDKChannelFeatures orig_conv;
40201         orig_conv.inner = (void*)(orig & (~1));
40202         orig_conv.is_owned = false;
40203         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40204         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
40205         int64_t ret_ref = 0;
40206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40209         ret_ref = (uintptr_t)ret_var.inner;
40210         if (ret_var.is_owned) {
40211                 ret_ref |= 1;
40212         }
40213         return ret_ref;
40214 }
40215
40216 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
40217         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
40218 int64_t ret_ref = 0;
40219 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40220 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40221 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40222 ret_ref = (uintptr_t)ret_var.inner;
40223 if (ret_var.is_owned) {
40224         ret_ref |= 1;
40225 }
40226         return ret_ref;
40227 }
40228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40229         LDKInvoiceFeatures arg_conv;
40230         arg_conv.inner = (void*)(arg & (~1));
40231         arg_conv.is_owned = false;
40232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40233         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
40234         return ret_conv;
40235 }
40236
40237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40238         LDKInvoiceFeatures orig_conv;
40239         orig_conv.inner = (void*)(orig & (~1));
40240         orig_conv.is_owned = false;
40241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40242         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
40243         int64_t ret_ref = 0;
40244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40247         ret_ref = (uintptr_t)ret_var.inner;
40248         if (ret_var.is_owned) {
40249                 ret_ref |= 1;
40250         }
40251         return ret_ref;
40252 }
40253
40254 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
40255         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
40256 int64_t ret_ref = 0;
40257 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40258 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40259 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40260 ret_ref = (uintptr_t)ret_var.inner;
40261 if (ret_var.is_owned) {
40262         ret_ref |= 1;
40263 }
40264         return ret_ref;
40265 }
40266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40267         LDKChannelTypeFeatures arg_conv;
40268         arg_conv.inner = (void*)(arg & (~1));
40269         arg_conv.is_owned = false;
40270         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40271         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
40272         return ret_conv;
40273 }
40274
40275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40276         LDKChannelTypeFeatures orig_conv;
40277         orig_conv.inner = (void*)(orig & (~1));
40278         orig_conv.is_owned = false;
40279         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40280         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_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_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40293         LDKInitFeatures this_obj_conv;
40294         this_obj_conv.inner = (void*)(this_obj & (~1));
40295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40297         InitFeatures_free(this_obj_conv);
40298 }
40299
40300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40301         LDKNodeFeatures this_obj_conv;
40302         this_obj_conv.inner = (void*)(this_obj & (~1));
40303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40305         NodeFeatures_free(this_obj_conv);
40306 }
40307
40308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40309         LDKChannelFeatures this_obj_conv;
40310         this_obj_conv.inner = (void*)(this_obj & (~1));
40311         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40313         ChannelFeatures_free(this_obj_conv);
40314 }
40315
40316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40317         LDKInvoiceFeatures this_obj_conv;
40318         this_obj_conv.inner = (void*)(this_obj & (~1));
40319         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40321         InvoiceFeatures_free(this_obj_conv);
40322 }
40323
40324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40325         LDKChannelTypeFeatures this_obj_conv;
40326         this_obj_conv.inner = (void*)(this_obj & (~1));
40327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40329         ChannelTypeFeatures_free(this_obj_conv);
40330 }
40331
40332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
40333         LDKInitFeatures ret_var = InitFeatures_empty();
40334         int64_t ret_ref = 0;
40335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40338         ret_ref = (uintptr_t)ret_var.inner;
40339         if (ret_var.is_owned) {
40340                 ret_ref |= 1;
40341         }
40342         return ret_ref;
40343 }
40344
40345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
40346         LDKInitFeatures ret_var = InitFeatures_known();
40347         int64_t ret_ref = 0;
40348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40351         ret_ref = (uintptr_t)ret_var.inner;
40352         if (ret_var.is_owned) {
40353                 ret_ref |= 1;
40354         }
40355         return ret_ref;
40356 }
40357
40358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40359         LDKInitFeatures this_arg_conv;
40360         this_arg_conv.inner = (void*)(this_arg & (~1));
40361         this_arg_conv.is_owned = false;
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40363         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
40364         return ret_conv;
40365 }
40366
40367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
40368         LDKNodeFeatures ret_var = NodeFeatures_empty();
40369         int64_t ret_ref = 0;
40370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40373         ret_ref = (uintptr_t)ret_var.inner;
40374         if (ret_var.is_owned) {
40375                 ret_ref |= 1;
40376         }
40377         return ret_ref;
40378 }
40379
40380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
40381         LDKNodeFeatures ret_var = NodeFeatures_known();
40382         int64_t ret_ref = 0;
40383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40386         ret_ref = (uintptr_t)ret_var.inner;
40387         if (ret_var.is_owned) {
40388                 ret_ref |= 1;
40389         }
40390         return ret_ref;
40391 }
40392
40393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40394         LDKNodeFeatures this_arg_conv;
40395         this_arg_conv.inner = (void*)(this_arg & (~1));
40396         this_arg_conv.is_owned = false;
40397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40398         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
40399         return ret_conv;
40400 }
40401
40402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
40403         LDKChannelFeatures ret_var = ChannelFeatures_empty();
40404         int64_t ret_ref = 0;
40405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40408         ret_ref = (uintptr_t)ret_var.inner;
40409         if (ret_var.is_owned) {
40410                 ret_ref |= 1;
40411         }
40412         return ret_ref;
40413 }
40414
40415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
40416         LDKChannelFeatures ret_var = ChannelFeatures_known();
40417         int64_t ret_ref = 0;
40418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40421         ret_ref = (uintptr_t)ret_var.inner;
40422         if (ret_var.is_owned) {
40423                 ret_ref |= 1;
40424         }
40425         return ret_ref;
40426 }
40427
40428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40429         LDKChannelFeatures this_arg_conv;
40430         this_arg_conv.inner = (void*)(this_arg & (~1));
40431         this_arg_conv.is_owned = false;
40432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40433         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
40434         return ret_conv;
40435 }
40436
40437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
40438         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
40439         int64_t ret_ref = 0;
40440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40443         ret_ref = (uintptr_t)ret_var.inner;
40444         if (ret_var.is_owned) {
40445                 ret_ref |= 1;
40446         }
40447         return ret_ref;
40448 }
40449
40450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
40451         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
40452         int64_t ret_ref = 0;
40453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40456         ret_ref = (uintptr_t)ret_var.inner;
40457         if (ret_var.is_owned) {
40458                 ret_ref |= 1;
40459         }
40460         return ret_ref;
40461 }
40462
40463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40464         LDKInvoiceFeatures this_arg_conv;
40465         this_arg_conv.inner = (void*)(this_arg & (~1));
40466         this_arg_conv.is_owned = false;
40467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40468         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
40469         return ret_conv;
40470 }
40471
40472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
40473         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
40474         int64_t ret_ref = 0;
40475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40478         ret_ref = (uintptr_t)ret_var.inner;
40479         if (ret_var.is_owned) {
40480                 ret_ref |= 1;
40481         }
40482         return ret_ref;
40483 }
40484
40485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
40486         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
40487         int64_t ret_ref = 0;
40488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40491         ret_ref = (uintptr_t)ret_var.inner;
40492         if (ret_var.is_owned) {
40493                 ret_ref |= 1;
40494         }
40495         return ret_ref;
40496 }
40497
40498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40499         LDKChannelTypeFeatures this_arg_conv;
40500         this_arg_conv.inner = (void*)(this_arg & (~1));
40501         this_arg_conv.is_owned = false;
40502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40503         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
40504         return ret_conv;
40505 }
40506
40507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40508         LDKInitFeatures obj_conv;
40509         obj_conv.inner = (void*)(obj & (~1));
40510         obj_conv.is_owned = false;
40511         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40512         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
40513         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40514         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40515         CVec_u8Z_free(ret_var);
40516         return ret_arr;
40517 }
40518
40519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40520         LDKu8slice ser_ref;
40521         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40522         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40523         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
40524         *ret_conv = InitFeatures_read(ser_ref);
40525         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40526         return (int64_t)ret_conv;
40527 }
40528
40529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40530         LDKChannelFeatures obj_conv;
40531         obj_conv.inner = (void*)(obj & (~1));
40532         obj_conv.is_owned = false;
40533         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40534         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
40535         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40536         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40537         CVec_u8Z_free(ret_var);
40538         return ret_arr;
40539 }
40540
40541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40542         LDKu8slice ser_ref;
40543         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40544         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40545         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
40546         *ret_conv = ChannelFeatures_read(ser_ref);
40547         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40548         return (int64_t)ret_conv;
40549 }
40550
40551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40552         LDKNodeFeatures obj_conv;
40553         obj_conv.inner = (void*)(obj & (~1));
40554         obj_conv.is_owned = false;
40555         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40556         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
40557         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40558         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40559         CVec_u8Z_free(ret_var);
40560         return ret_arr;
40561 }
40562
40563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40564         LDKu8slice ser_ref;
40565         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40566         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40567         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
40568         *ret_conv = NodeFeatures_read(ser_ref);
40569         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40570         return (int64_t)ret_conv;
40571 }
40572
40573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40574         LDKInvoiceFeatures obj_conv;
40575         obj_conv.inner = (void*)(obj & (~1));
40576         obj_conv.is_owned = false;
40577         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40578         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
40579         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40580         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40581         CVec_u8Z_free(ret_var);
40582         return ret_arr;
40583 }
40584
40585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40586         LDKu8slice ser_ref;
40587         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40588         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40589         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
40590         *ret_conv = InvoiceFeatures_read(ser_ref);
40591         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40592         return (int64_t)ret_conv;
40593 }
40594
40595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40596         LDKChannelTypeFeatures obj_conv;
40597         obj_conv.inner = (void*)(obj & (~1));
40598         obj_conv.is_owned = false;
40599         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40600         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
40601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40603         CVec_u8Z_free(ret_var);
40604         return ret_arr;
40605 }
40606
40607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40608         LDKu8slice ser_ref;
40609         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40610         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40611         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
40612         *ret_conv = ChannelTypeFeatures_read(ser_ref);
40613         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40614         return (int64_t)ret_conv;
40615 }
40616
40617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40618         LDKInitFeatures this_arg_conv;
40619         this_arg_conv.inner = (void*)(this_arg & (~1));
40620         this_arg_conv.is_owned = false;
40621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40622         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
40623 }
40624
40625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40626         LDKInitFeatures this_arg_conv;
40627         this_arg_conv.inner = (void*)(this_arg & (~1));
40628         this_arg_conv.is_owned = false;
40629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40630         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
40631 }
40632
40633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40634         LDKInitFeatures this_arg_conv;
40635         this_arg_conv.inner = (void*)(this_arg & (~1));
40636         this_arg_conv.is_owned = false;
40637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40638         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
40639         return ret_conv;
40640 }
40641
40642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40643         LDKNodeFeatures this_arg_conv;
40644         this_arg_conv.inner = (void*)(this_arg & (~1));
40645         this_arg_conv.is_owned = false;
40646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40647         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
40648 }
40649
40650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40651         LDKNodeFeatures this_arg_conv;
40652         this_arg_conv.inner = (void*)(this_arg & (~1));
40653         this_arg_conv.is_owned = false;
40654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40655         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
40656 }
40657
40658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40659         LDKNodeFeatures this_arg_conv;
40660         this_arg_conv.inner = (void*)(this_arg & (~1));
40661         this_arg_conv.is_owned = false;
40662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40663         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
40664         return ret_conv;
40665 }
40666
40667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40668         LDKInitFeatures this_arg_conv;
40669         this_arg_conv.inner = (void*)(this_arg & (~1));
40670         this_arg_conv.is_owned = false;
40671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40672         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
40673         return ret_conv;
40674 }
40675
40676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40677         LDKNodeFeatures this_arg_conv;
40678         this_arg_conv.inner = (void*)(this_arg & (~1));
40679         this_arg_conv.is_owned = false;
40680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40681         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
40682         return ret_conv;
40683 }
40684
40685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40686         LDKInitFeatures this_arg_conv;
40687         this_arg_conv.inner = (void*)(this_arg & (~1));
40688         this_arg_conv.is_owned = false;
40689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40690         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
40691 }
40692
40693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40694         LDKInitFeatures this_arg_conv;
40695         this_arg_conv.inner = (void*)(this_arg & (~1));
40696         this_arg_conv.is_owned = false;
40697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40698         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
40699 }
40700
40701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
40702         LDKInitFeatures this_arg_conv;
40703         this_arg_conv.inner = (void*)(this_arg & (~1));
40704         this_arg_conv.is_owned = false;
40705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40706         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
40707         return ret_conv;
40708 }
40709
40710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40711         LDKInitFeatures this_arg_conv;
40712         this_arg_conv.inner = (void*)(this_arg & (~1));
40713         this_arg_conv.is_owned = false;
40714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40715         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
40716 }
40717
40718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40719         LDKInitFeatures this_arg_conv;
40720         this_arg_conv.inner = (void*)(this_arg & (~1));
40721         this_arg_conv.is_owned = false;
40722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40723         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
40724 }
40725
40726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40727         LDKInitFeatures this_arg_conv;
40728         this_arg_conv.inner = (void*)(this_arg & (~1));
40729         this_arg_conv.is_owned = false;
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40731         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
40732         return ret_conv;
40733 }
40734
40735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40736         LDKNodeFeatures this_arg_conv;
40737         this_arg_conv.inner = (void*)(this_arg & (~1));
40738         this_arg_conv.is_owned = false;
40739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40740         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
40741 }
40742
40743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40744         LDKNodeFeatures this_arg_conv;
40745         this_arg_conv.inner = (void*)(this_arg & (~1));
40746         this_arg_conv.is_owned = false;
40747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40748         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
40749 }
40750
40751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40752         LDKNodeFeatures this_arg_conv;
40753         this_arg_conv.inner = (void*)(this_arg & (~1));
40754         this_arg_conv.is_owned = false;
40755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40756         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
40757         return ret_conv;
40758 }
40759
40760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40761         LDKInitFeatures this_arg_conv;
40762         this_arg_conv.inner = (void*)(this_arg & (~1));
40763         this_arg_conv.is_owned = false;
40764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40765         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
40766         return ret_conv;
40767 }
40768
40769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40770         LDKNodeFeatures this_arg_conv;
40771         this_arg_conv.inner = (void*)(this_arg & (~1));
40772         this_arg_conv.is_owned = false;
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40774         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
40775         return ret_conv;
40776 }
40777
40778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40779         LDKInitFeatures this_arg_conv;
40780         this_arg_conv.inner = (void*)(this_arg & (~1));
40781         this_arg_conv.is_owned = false;
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40783         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
40784 }
40785
40786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40787         LDKInitFeatures this_arg_conv;
40788         this_arg_conv.inner = (void*)(this_arg & (~1));
40789         this_arg_conv.is_owned = false;
40790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40791         InitFeatures_set_gossip_queries_required(&this_arg_conv);
40792 }
40793
40794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40795         LDKInitFeatures this_arg_conv;
40796         this_arg_conv.inner = (void*)(this_arg & (~1));
40797         this_arg_conv.is_owned = false;
40798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40799         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
40800         return ret_conv;
40801 }
40802
40803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40804         LDKNodeFeatures this_arg_conv;
40805         this_arg_conv.inner = (void*)(this_arg & (~1));
40806         this_arg_conv.is_owned = false;
40807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40808         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
40809 }
40810
40811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40812         LDKNodeFeatures this_arg_conv;
40813         this_arg_conv.inner = (void*)(this_arg & (~1));
40814         this_arg_conv.is_owned = false;
40815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40816         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
40817 }
40818
40819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40820         LDKNodeFeatures this_arg_conv;
40821         this_arg_conv.inner = (void*)(this_arg & (~1));
40822         this_arg_conv.is_owned = false;
40823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40824         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
40825         return ret_conv;
40826 }
40827
40828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40829         LDKInitFeatures this_arg_conv;
40830         this_arg_conv.inner = (void*)(this_arg & (~1));
40831         this_arg_conv.is_owned = false;
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40833         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
40834         return ret_conv;
40835 }
40836
40837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40838         LDKNodeFeatures this_arg_conv;
40839         this_arg_conv.inner = (void*)(this_arg & (~1));
40840         this_arg_conv.is_owned = false;
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40842         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
40843         return ret_conv;
40844 }
40845
40846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40847         LDKInitFeatures this_arg_conv;
40848         this_arg_conv.inner = (void*)(this_arg & (~1));
40849         this_arg_conv.is_owned = false;
40850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40851         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
40852 }
40853
40854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40855         LDKInitFeatures this_arg_conv;
40856         this_arg_conv.inner = (void*)(this_arg & (~1));
40857         this_arg_conv.is_owned = false;
40858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40859         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
40860 }
40861
40862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40863         LDKInitFeatures this_arg_conv;
40864         this_arg_conv.inner = (void*)(this_arg & (~1));
40865         this_arg_conv.is_owned = false;
40866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40867         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
40868         return ret_conv;
40869 }
40870
40871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40872         LDKNodeFeatures this_arg_conv;
40873         this_arg_conv.inner = (void*)(this_arg & (~1));
40874         this_arg_conv.is_owned = false;
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40876         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
40877 }
40878
40879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40880         LDKNodeFeatures this_arg_conv;
40881         this_arg_conv.inner = (void*)(this_arg & (~1));
40882         this_arg_conv.is_owned = false;
40883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40884         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
40885 }
40886
40887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40888         LDKNodeFeatures this_arg_conv;
40889         this_arg_conv.inner = (void*)(this_arg & (~1));
40890         this_arg_conv.is_owned = false;
40891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40892         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
40893         return ret_conv;
40894 }
40895
40896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40897         LDKInvoiceFeatures this_arg_conv;
40898         this_arg_conv.inner = (void*)(this_arg & (~1));
40899         this_arg_conv.is_owned = false;
40900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40901         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
40902 }
40903
40904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40905         LDKInvoiceFeatures this_arg_conv;
40906         this_arg_conv.inner = (void*)(this_arg & (~1));
40907         this_arg_conv.is_owned = false;
40908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40909         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
40910 }
40911
40912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40913         LDKInvoiceFeatures this_arg_conv;
40914         this_arg_conv.inner = (void*)(this_arg & (~1));
40915         this_arg_conv.is_owned = false;
40916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40917         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
40918         return ret_conv;
40919 }
40920
40921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40922         LDKInitFeatures this_arg_conv;
40923         this_arg_conv.inner = (void*)(this_arg & (~1));
40924         this_arg_conv.is_owned = false;
40925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40926         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
40927         return ret_conv;
40928 }
40929
40930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40931         LDKNodeFeatures this_arg_conv;
40932         this_arg_conv.inner = (void*)(this_arg & (~1));
40933         this_arg_conv.is_owned = false;
40934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40935         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
40936         return ret_conv;
40937 }
40938
40939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40940         LDKInvoiceFeatures this_arg_conv;
40941         this_arg_conv.inner = (void*)(this_arg & (~1));
40942         this_arg_conv.is_owned = false;
40943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40944         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
40945         return ret_conv;
40946 }
40947
40948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40949         LDKInitFeatures this_arg_conv;
40950         this_arg_conv.inner = (void*)(this_arg & (~1));
40951         this_arg_conv.is_owned = false;
40952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40953         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
40954 }
40955
40956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40957         LDKInitFeatures this_arg_conv;
40958         this_arg_conv.inner = (void*)(this_arg & (~1));
40959         this_arg_conv.is_owned = false;
40960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40961         InitFeatures_set_static_remote_key_required(&this_arg_conv);
40962 }
40963
40964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40965         LDKInitFeatures this_arg_conv;
40966         this_arg_conv.inner = (void*)(this_arg & (~1));
40967         this_arg_conv.is_owned = false;
40968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40969         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
40970         return ret_conv;
40971 }
40972
40973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40974         LDKNodeFeatures this_arg_conv;
40975         this_arg_conv.inner = (void*)(this_arg & (~1));
40976         this_arg_conv.is_owned = false;
40977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40978         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
40979 }
40980
40981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40982         LDKNodeFeatures this_arg_conv;
40983         this_arg_conv.inner = (void*)(this_arg & (~1));
40984         this_arg_conv.is_owned = false;
40985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40986         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
40987 }
40988
40989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40990         LDKNodeFeatures this_arg_conv;
40991         this_arg_conv.inner = (void*)(this_arg & (~1));
40992         this_arg_conv.is_owned = false;
40993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40994         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
40995         return ret_conv;
40996 }
40997
40998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40999         LDKChannelTypeFeatures this_arg_conv;
41000         this_arg_conv.inner = (void*)(this_arg & (~1));
41001         this_arg_conv.is_owned = false;
41002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41003         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
41004 }
41005
41006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41007         LDKChannelTypeFeatures this_arg_conv;
41008         this_arg_conv.inner = (void*)(this_arg & (~1));
41009         this_arg_conv.is_owned = false;
41010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41011         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
41012 }
41013
41014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41015         LDKChannelTypeFeatures this_arg_conv;
41016         this_arg_conv.inner = (void*)(this_arg & (~1));
41017         this_arg_conv.is_owned = false;
41018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41019         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
41020         return ret_conv;
41021 }
41022
41023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41024         LDKInitFeatures this_arg_conv;
41025         this_arg_conv.inner = (void*)(this_arg & (~1));
41026         this_arg_conv.is_owned = false;
41027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41028         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
41029         return ret_conv;
41030 }
41031
41032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41033         LDKNodeFeatures this_arg_conv;
41034         this_arg_conv.inner = (void*)(this_arg & (~1));
41035         this_arg_conv.is_owned = false;
41036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41037         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
41038         return ret_conv;
41039 }
41040
41041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41042         LDKChannelTypeFeatures this_arg_conv;
41043         this_arg_conv.inner = (void*)(this_arg & (~1));
41044         this_arg_conv.is_owned = false;
41045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41046         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
41047         return ret_conv;
41048 }
41049
41050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41051         LDKInitFeatures this_arg_conv;
41052         this_arg_conv.inner = (void*)(this_arg & (~1));
41053         this_arg_conv.is_owned = false;
41054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41055         InitFeatures_set_payment_secret_optional(&this_arg_conv);
41056 }
41057
41058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41059         LDKInitFeatures this_arg_conv;
41060         this_arg_conv.inner = (void*)(this_arg & (~1));
41061         this_arg_conv.is_owned = false;
41062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41063         InitFeatures_set_payment_secret_required(&this_arg_conv);
41064 }
41065
41066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41067         LDKInitFeatures this_arg_conv;
41068         this_arg_conv.inner = (void*)(this_arg & (~1));
41069         this_arg_conv.is_owned = false;
41070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41071         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
41072         return ret_conv;
41073 }
41074
41075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41076         LDKNodeFeatures this_arg_conv;
41077         this_arg_conv.inner = (void*)(this_arg & (~1));
41078         this_arg_conv.is_owned = false;
41079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41080         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
41081 }
41082
41083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41084         LDKNodeFeatures this_arg_conv;
41085         this_arg_conv.inner = (void*)(this_arg & (~1));
41086         this_arg_conv.is_owned = false;
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41088         NodeFeatures_set_payment_secret_required(&this_arg_conv);
41089 }
41090
41091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41092         LDKNodeFeatures this_arg_conv;
41093         this_arg_conv.inner = (void*)(this_arg & (~1));
41094         this_arg_conv.is_owned = false;
41095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41096         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
41097         return ret_conv;
41098 }
41099
41100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41101         LDKInvoiceFeatures this_arg_conv;
41102         this_arg_conv.inner = (void*)(this_arg & (~1));
41103         this_arg_conv.is_owned = false;
41104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41105         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
41106 }
41107
41108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41109         LDKInvoiceFeatures this_arg_conv;
41110         this_arg_conv.inner = (void*)(this_arg & (~1));
41111         this_arg_conv.is_owned = false;
41112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41113         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
41114 }
41115
41116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41117         LDKInvoiceFeatures this_arg_conv;
41118         this_arg_conv.inner = (void*)(this_arg & (~1));
41119         this_arg_conv.is_owned = false;
41120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41121         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
41122         return ret_conv;
41123 }
41124
41125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41126         LDKInitFeatures this_arg_conv;
41127         this_arg_conv.inner = (void*)(this_arg & (~1));
41128         this_arg_conv.is_owned = false;
41129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41130         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
41131         return ret_conv;
41132 }
41133
41134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41135         LDKNodeFeatures this_arg_conv;
41136         this_arg_conv.inner = (void*)(this_arg & (~1));
41137         this_arg_conv.is_owned = false;
41138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41139         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
41140         return ret_conv;
41141 }
41142
41143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41144         LDKInvoiceFeatures this_arg_conv;
41145         this_arg_conv.inner = (void*)(this_arg & (~1));
41146         this_arg_conv.is_owned = false;
41147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41148         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
41149         return ret_conv;
41150 }
41151
41152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41153         LDKInitFeatures this_arg_conv;
41154         this_arg_conv.inner = (void*)(this_arg & (~1));
41155         this_arg_conv.is_owned = false;
41156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41157         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
41158 }
41159
41160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41161         LDKInitFeatures this_arg_conv;
41162         this_arg_conv.inner = (void*)(this_arg & (~1));
41163         this_arg_conv.is_owned = false;
41164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41165         InitFeatures_set_basic_mpp_required(&this_arg_conv);
41166 }
41167
41168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41169         LDKInitFeatures this_arg_conv;
41170         this_arg_conv.inner = (void*)(this_arg & (~1));
41171         this_arg_conv.is_owned = false;
41172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41173         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
41174         return ret_conv;
41175 }
41176
41177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41178         LDKNodeFeatures this_arg_conv;
41179         this_arg_conv.inner = (void*)(this_arg & (~1));
41180         this_arg_conv.is_owned = false;
41181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41182         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
41183 }
41184
41185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41186         LDKNodeFeatures this_arg_conv;
41187         this_arg_conv.inner = (void*)(this_arg & (~1));
41188         this_arg_conv.is_owned = false;
41189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41190         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
41191 }
41192
41193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41194         LDKNodeFeatures this_arg_conv;
41195         this_arg_conv.inner = (void*)(this_arg & (~1));
41196         this_arg_conv.is_owned = false;
41197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41198         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
41199         return ret_conv;
41200 }
41201
41202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41203         LDKInvoiceFeatures this_arg_conv;
41204         this_arg_conv.inner = (void*)(this_arg & (~1));
41205         this_arg_conv.is_owned = false;
41206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41207         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
41208 }
41209
41210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41211         LDKInvoiceFeatures this_arg_conv;
41212         this_arg_conv.inner = (void*)(this_arg & (~1));
41213         this_arg_conv.is_owned = false;
41214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41215         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
41216 }
41217
41218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41219         LDKInvoiceFeatures this_arg_conv;
41220         this_arg_conv.inner = (void*)(this_arg & (~1));
41221         this_arg_conv.is_owned = false;
41222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41223         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
41224         return ret_conv;
41225 }
41226
41227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41228         LDKInitFeatures this_arg_conv;
41229         this_arg_conv.inner = (void*)(this_arg & (~1));
41230         this_arg_conv.is_owned = false;
41231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41232         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
41233         return ret_conv;
41234 }
41235
41236 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41237         LDKNodeFeatures this_arg_conv;
41238         this_arg_conv.inner = (void*)(this_arg & (~1));
41239         this_arg_conv.is_owned = false;
41240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41241         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
41242         return ret_conv;
41243 }
41244
41245 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41246         LDKInvoiceFeatures this_arg_conv;
41247         this_arg_conv.inner = (void*)(this_arg & (~1));
41248         this_arg_conv.is_owned = false;
41249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41250         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
41251         return ret_conv;
41252 }
41253
41254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41255         LDKInitFeatures this_arg_conv;
41256         this_arg_conv.inner = (void*)(this_arg & (~1));
41257         this_arg_conv.is_owned = false;
41258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41259         InitFeatures_set_wumbo_optional(&this_arg_conv);
41260 }
41261
41262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41263         LDKInitFeatures this_arg_conv;
41264         this_arg_conv.inner = (void*)(this_arg & (~1));
41265         this_arg_conv.is_owned = false;
41266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41267         InitFeatures_set_wumbo_required(&this_arg_conv);
41268 }
41269
41270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41271         LDKInitFeatures this_arg_conv;
41272         this_arg_conv.inner = (void*)(this_arg & (~1));
41273         this_arg_conv.is_owned = false;
41274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41275         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
41276         return ret_conv;
41277 }
41278
41279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41280         LDKNodeFeatures this_arg_conv;
41281         this_arg_conv.inner = (void*)(this_arg & (~1));
41282         this_arg_conv.is_owned = false;
41283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41284         NodeFeatures_set_wumbo_optional(&this_arg_conv);
41285 }
41286
41287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41288         LDKNodeFeatures this_arg_conv;
41289         this_arg_conv.inner = (void*)(this_arg & (~1));
41290         this_arg_conv.is_owned = false;
41291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41292         NodeFeatures_set_wumbo_required(&this_arg_conv);
41293 }
41294
41295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41296         LDKNodeFeatures this_arg_conv;
41297         this_arg_conv.inner = (void*)(this_arg & (~1));
41298         this_arg_conv.is_owned = false;
41299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41300         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
41301         return ret_conv;
41302 }
41303
41304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41305         LDKInitFeatures this_arg_conv;
41306         this_arg_conv.inner = (void*)(this_arg & (~1));
41307         this_arg_conv.is_owned = false;
41308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41309         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
41310         return ret_conv;
41311 }
41312
41313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41314         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
41319         return ret_conv;
41320 }
41321
41322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41323         LDKInitFeatures this_arg_conv;
41324         this_arg_conv.inner = (void*)(this_arg & (~1));
41325         this_arg_conv.is_owned = false;
41326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41327         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
41328 }
41329
41330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41331         LDKInitFeatures this_arg_conv;
41332         this_arg_conv.inner = (void*)(this_arg & (~1));
41333         this_arg_conv.is_owned = false;
41334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41335         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
41336 }
41337
41338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41339         LDKInitFeatures this_arg_conv;
41340         this_arg_conv.inner = (void*)(this_arg & (~1));
41341         this_arg_conv.is_owned = false;
41342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41343         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
41344         return ret_conv;
41345 }
41346
41347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41348         LDKNodeFeatures this_arg_conv;
41349         this_arg_conv.inner = (void*)(this_arg & (~1));
41350         this_arg_conv.is_owned = false;
41351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41352         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
41353 }
41354
41355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41356         LDKNodeFeatures this_arg_conv;
41357         this_arg_conv.inner = (void*)(this_arg & (~1));
41358         this_arg_conv.is_owned = false;
41359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41360         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
41361 }
41362
41363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41364         LDKNodeFeatures this_arg_conv;
41365         this_arg_conv.inner = (void*)(this_arg & (~1));
41366         this_arg_conv.is_owned = false;
41367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41368         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
41369         return ret_conv;
41370 }
41371
41372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41373         LDKInitFeatures this_arg_conv;
41374         this_arg_conv.inner = (void*)(this_arg & (~1));
41375         this_arg_conv.is_owned = false;
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41377         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
41378         return ret_conv;
41379 }
41380
41381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41382         LDKNodeFeatures this_arg_conv;
41383         this_arg_conv.inner = (void*)(this_arg & (~1));
41384         this_arg_conv.is_owned = false;
41385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41386         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
41387         return ret_conv;
41388 }
41389
41390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41391         LDKInitFeatures this_arg_conv;
41392         this_arg_conv.inner = (void*)(this_arg & (~1));
41393         this_arg_conv.is_owned = false;
41394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41395         InitFeatures_set_channel_type_optional(&this_arg_conv);
41396 }
41397
41398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41399         LDKInitFeatures this_arg_conv;
41400         this_arg_conv.inner = (void*)(this_arg & (~1));
41401         this_arg_conv.is_owned = false;
41402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41403         InitFeatures_set_channel_type_required(&this_arg_conv);
41404 }
41405
41406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41407         LDKInitFeatures this_arg_conv;
41408         this_arg_conv.inner = (void*)(this_arg & (~1));
41409         this_arg_conv.is_owned = false;
41410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41411         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
41412         return ret_conv;
41413 }
41414
41415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41416         LDKNodeFeatures this_arg_conv;
41417         this_arg_conv.inner = (void*)(this_arg & (~1));
41418         this_arg_conv.is_owned = false;
41419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41420         NodeFeatures_set_channel_type_optional(&this_arg_conv);
41421 }
41422
41423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41424         LDKNodeFeatures this_arg_conv;
41425         this_arg_conv.inner = (void*)(this_arg & (~1));
41426         this_arg_conv.is_owned = false;
41427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41428         NodeFeatures_set_channel_type_required(&this_arg_conv);
41429 }
41430
41431 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41432         LDKNodeFeatures this_arg_conv;
41433         this_arg_conv.inner = (void*)(this_arg & (~1));
41434         this_arg_conv.is_owned = false;
41435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41436         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
41437         return ret_conv;
41438 }
41439
41440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41441         LDKInitFeatures 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         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
41446         return ret_conv;
41447 }
41448
41449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41450         LDKNodeFeatures this_arg_conv;
41451         this_arg_conv.inner = (void*)(this_arg & (~1));
41452         this_arg_conv.is_owned = false;
41453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41454         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
41455         return ret_conv;
41456 }
41457
41458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41459         LDKInitFeatures this_arg_conv;
41460         this_arg_conv.inner = (void*)(this_arg & (~1));
41461         this_arg_conv.is_owned = false;
41462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41463         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
41464 }
41465
41466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41467         LDKInitFeatures this_arg_conv;
41468         this_arg_conv.inner = (void*)(this_arg & (~1));
41469         this_arg_conv.is_owned = false;
41470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41471         InitFeatures_set_scid_privacy_required(&this_arg_conv);
41472 }
41473
41474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41475         LDKInitFeatures this_arg_conv;
41476         this_arg_conv.inner = (void*)(this_arg & (~1));
41477         this_arg_conv.is_owned = false;
41478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41479         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
41480         return ret_conv;
41481 }
41482
41483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41484         LDKNodeFeatures this_arg_conv;
41485         this_arg_conv.inner = (void*)(this_arg & (~1));
41486         this_arg_conv.is_owned = false;
41487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41488         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
41489 }
41490
41491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41492         LDKNodeFeatures this_arg_conv;
41493         this_arg_conv.inner = (void*)(this_arg & (~1));
41494         this_arg_conv.is_owned = false;
41495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41496         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
41497 }
41498
41499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41500         LDKNodeFeatures this_arg_conv;
41501         this_arg_conv.inner = (void*)(this_arg & (~1));
41502         this_arg_conv.is_owned = false;
41503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41504         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
41505         return ret_conv;
41506 }
41507
41508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41509         LDKChannelTypeFeatures this_arg_conv;
41510         this_arg_conv.inner = (void*)(this_arg & (~1));
41511         this_arg_conv.is_owned = false;
41512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41513         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
41514 }
41515
41516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41517         LDKChannelTypeFeatures this_arg_conv;
41518         this_arg_conv.inner = (void*)(this_arg & (~1));
41519         this_arg_conv.is_owned = false;
41520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41521         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
41522 }
41523
41524 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41525         LDKChannelTypeFeatures this_arg_conv;
41526         this_arg_conv.inner = (void*)(this_arg & (~1));
41527         this_arg_conv.is_owned = false;
41528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41529         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
41530         return ret_conv;
41531 }
41532
41533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41534         LDKInitFeatures this_arg_conv;
41535         this_arg_conv.inner = (void*)(this_arg & (~1));
41536         this_arg_conv.is_owned = false;
41537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41538         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
41539         return ret_conv;
41540 }
41541
41542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41543         LDKNodeFeatures this_arg_conv;
41544         this_arg_conv.inner = (void*)(this_arg & (~1));
41545         this_arg_conv.is_owned = false;
41546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41547         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
41548         return ret_conv;
41549 }
41550
41551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41552         LDKChannelTypeFeatures this_arg_conv;
41553         this_arg_conv.inner = (void*)(this_arg & (~1));
41554         this_arg_conv.is_owned = false;
41555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41556         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
41557         return ret_conv;
41558 }
41559
41560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41561         LDKInitFeatures this_arg_conv;
41562         this_arg_conv.inner = (void*)(this_arg & (~1));
41563         this_arg_conv.is_owned = false;
41564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41565         InitFeatures_set_zero_conf_optional(&this_arg_conv);
41566 }
41567
41568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41569         LDKInitFeatures this_arg_conv;
41570         this_arg_conv.inner = (void*)(this_arg & (~1));
41571         this_arg_conv.is_owned = false;
41572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41573         InitFeatures_set_zero_conf_required(&this_arg_conv);
41574 }
41575
41576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41577         LDKInitFeatures this_arg_conv;
41578         this_arg_conv.inner = (void*)(this_arg & (~1));
41579         this_arg_conv.is_owned = false;
41580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41581         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
41582         return ret_conv;
41583 }
41584
41585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41586         LDKNodeFeatures this_arg_conv;
41587         this_arg_conv.inner = (void*)(this_arg & (~1));
41588         this_arg_conv.is_owned = false;
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41590         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
41591 }
41592
41593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41594         LDKNodeFeatures this_arg_conv;
41595         this_arg_conv.inner = (void*)(this_arg & (~1));
41596         this_arg_conv.is_owned = false;
41597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41598         NodeFeatures_set_zero_conf_required(&this_arg_conv);
41599 }
41600
41601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41602         LDKNodeFeatures this_arg_conv;
41603         this_arg_conv.inner = (void*)(this_arg & (~1));
41604         this_arg_conv.is_owned = false;
41605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41606         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
41607         return ret_conv;
41608 }
41609
41610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41611         LDKChannelTypeFeatures this_arg_conv;
41612         this_arg_conv.inner = (void*)(this_arg & (~1));
41613         this_arg_conv.is_owned = false;
41614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41615         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
41616 }
41617
41618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41619         LDKChannelTypeFeatures this_arg_conv;
41620         this_arg_conv.inner = (void*)(this_arg & (~1));
41621         this_arg_conv.is_owned = false;
41622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41623         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
41624 }
41625
41626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41627         LDKChannelTypeFeatures this_arg_conv;
41628         this_arg_conv.inner = (void*)(this_arg & (~1));
41629         this_arg_conv.is_owned = false;
41630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41631         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
41632         return ret_conv;
41633 }
41634
41635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41636         LDKInitFeatures this_arg_conv;
41637         this_arg_conv.inner = (void*)(this_arg & (~1));
41638         this_arg_conv.is_owned = false;
41639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41640         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
41641         return ret_conv;
41642 }
41643
41644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41645         LDKNodeFeatures this_arg_conv;
41646         this_arg_conv.inner = (void*)(this_arg & (~1));
41647         this_arg_conv.is_owned = false;
41648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41649         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
41650         return ret_conv;
41651 }
41652
41653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41654         LDKChannelTypeFeatures this_arg_conv;
41655         this_arg_conv.inner = (void*)(this_arg & (~1));
41656         this_arg_conv.is_owned = false;
41657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41658         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
41659         return ret_conv;
41660 }
41661
41662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41663         LDKNodeFeatures this_arg_conv;
41664         this_arg_conv.inner = (void*)(this_arg & (~1));
41665         this_arg_conv.is_owned = false;
41666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41667         NodeFeatures_set_keysend_optional(&this_arg_conv);
41668 }
41669
41670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41671         LDKNodeFeatures this_arg_conv;
41672         this_arg_conv.inner = (void*)(this_arg & (~1));
41673         this_arg_conv.is_owned = false;
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41675         NodeFeatures_set_keysend_required(&this_arg_conv);
41676 }
41677
41678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
41679         LDKNodeFeatures this_arg_conv;
41680         this_arg_conv.inner = (void*)(this_arg & (~1));
41681         this_arg_conv.is_owned = false;
41682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41683         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
41684         return ret_conv;
41685 }
41686
41687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
41688         LDKNodeFeatures this_arg_conv;
41689         this_arg_conv.inner = (void*)(this_arg & (~1));
41690         this_arg_conv.is_owned = false;
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41692         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
41693         return ret_conv;
41694 }
41695
41696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41697         LDKShutdownScript this_obj_conv;
41698         this_obj_conv.inner = (void*)(this_obj & (~1));
41699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41701         ShutdownScript_free(this_obj_conv);
41702 }
41703
41704 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
41705         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
41706 int64_t ret_ref = 0;
41707 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41708 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41709 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41710 ret_ref = (uintptr_t)ret_var.inner;
41711 if (ret_var.is_owned) {
41712         ret_ref |= 1;
41713 }
41714         return ret_ref;
41715 }
41716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41717         LDKShutdownScript arg_conv;
41718         arg_conv.inner = (void*)(arg & (~1));
41719         arg_conv.is_owned = false;
41720         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41721         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
41722         return ret_conv;
41723 }
41724
41725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41726         LDKShutdownScript orig_conv;
41727         orig_conv.inner = (void*)(orig & (~1));
41728         orig_conv.is_owned = false;
41729         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41730         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
41731         int64_t ret_ref = 0;
41732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41735         ret_ref = (uintptr_t)ret_var.inner;
41736         if (ret_var.is_owned) {
41737                 ret_ref |= 1;
41738         }
41739         return ret_ref;
41740 }
41741
41742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41743         LDKInvalidShutdownScript this_obj_conv;
41744         this_obj_conv.inner = (void*)(this_obj & (~1));
41745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41747         InvalidShutdownScript_free(this_obj_conv);
41748 }
41749
41750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
41751         LDKInvalidShutdownScript this_ptr_conv;
41752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41753         this_ptr_conv.is_owned = false;
41754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41755         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
41756         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41757         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41758         return ret_arr;
41759 }
41760
41761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41762         LDKInvalidShutdownScript this_ptr_conv;
41763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41764         this_ptr_conv.is_owned = false;
41765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41766         LDKCVec_u8Z val_ref;
41767         val_ref.datalen = (*env)->GetArrayLength(env, val);
41768         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41769         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
41770         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
41771 }
41772
41773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
41774         LDKCVec_u8Z script_arg_ref;
41775         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
41776         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41777         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
41778         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
41779         int64_t ret_ref = 0;
41780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41783         ret_ref = (uintptr_t)ret_var.inner;
41784         if (ret_var.is_owned) {
41785                 ret_ref |= 1;
41786         }
41787         return ret_ref;
41788 }
41789
41790 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
41791         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
41792 int64_t ret_ref = 0;
41793 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41794 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41795 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41796 ret_ref = (uintptr_t)ret_var.inner;
41797 if (ret_var.is_owned) {
41798         ret_ref |= 1;
41799 }
41800         return ret_ref;
41801 }
41802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41803         LDKInvalidShutdownScript arg_conv;
41804         arg_conv.inner = (void*)(arg & (~1));
41805         arg_conv.is_owned = false;
41806         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41807         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
41808         return ret_conv;
41809 }
41810
41811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41812         LDKInvalidShutdownScript orig_conv;
41813         orig_conv.inner = (void*)(orig & (~1));
41814         orig_conv.is_owned = false;
41815         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41816         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
41817         int64_t ret_ref = 0;
41818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41821         ret_ref = (uintptr_t)ret_var.inner;
41822         if (ret_var.is_owned) {
41823                 ret_ref |= 1;
41824         }
41825         return ret_ref;
41826 }
41827
41828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
41829         LDKShutdownScript obj_conv;
41830         obj_conv.inner = (void*)(obj & (~1));
41831         obj_conv.is_owned = false;
41832         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41833         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
41834         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41835         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41836         CVec_u8Z_free(ret_var);
41837         return ret_arr;
41838 }
41839
41840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41841         LDKu8slice ser_ref;
41842         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41843         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41844         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
41845         *ret_conv = ShutdownScript_read(ser_ref);
41846         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41847         return (int64_t)ret_conv;
41848 }
41849
41850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
41851         unsigned char pubkey_hash_arr[20];
41852         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
41853         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
41854         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
41855         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
41856         int64_t ret_ref = 0;
41857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41860         ret_ref = (uintptr_t)ret_var.inner;
41861         if (ret_var.is_owned) {
41862                 ret_ref |= 1;
41863         }
41864         return ret_ref;
41865 }
41866
41867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
41868         unsigned char script_hash_arr[32];
41869         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
41870         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
41871         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
41872         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
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
41884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
41885         
41886         LDKu8slice program_ref;
41887         program_ref.datalen = (*env)->GetArrayLength(env, program);
41888         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
41889         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
41890         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
41891         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
41892         return (int64_t)ret_conv;
41893 }
41894
41895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
41896         LDKShutdownScript this_arg_conv;
41897         this_arg_conv.inner = (void*)(this_arg & (~1));
41898         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41900         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
41901         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
41902         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41903         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41904         CVec_u8Z_free(ret_var);
41905         return ret_arr;
41906 }
41907
41908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
41909         LDKShutdownScript this_arg_conv;
41910         this_arg_conv.inner = (void*)(this_arg & (~1));
41911         this_arg_conv.is_owned = false;
41912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41913         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
41915         return ret_arr;
41916 }
41917
41918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
41919         LDKShutdownScript this_arg_conv;
41920         this_arg_conv.inner = (void*)(this_arg & (~1));
41921         this_arg_conv.is_owned = false;
41922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41923         LDKInitFeatures features_conv;
41924         features_conv.inner = (void*)(features & (~1));
41925         features_conv.is_owned = false;
41926         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
41927         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
41928         return ret_conv;
41929 }
41930
41931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41932         if ((this_ptr & 1) != 0) return;
41933         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41934         CHECK_ACCESS(this_ptr_ptr);
41935         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
41936         FREE((void*)this_ptr);
41937         CustomMessageReader_free(this_ptr_conv);
41938 }
41939
41940 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
41941         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41942         *ret_ret = Type_clone(arg);
41943         return (int64_t)ret_ret;
41944 }
41945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41946         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
41947         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
41948         LDKType* arg_conv = (LDKType*)arg_ptr;
41949         int64_t ret_conv = Type_clone_ptr(arg_conv);
41950         return ret_conv;
41951 }
41952
41953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41954         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
41955         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
41956         LDKType* orig_conv = (LDKType*)orig_ptr;
41957         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41958         *ret_ret = Type_clone(orig_conv);
41959         return (int64_t)ret_ret;
41960 }
41961
41962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41963         if ((this_ptr & 1) != 0) return;
41964         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41965         CHECK_ACCESS(this_ptr_ptr);
41966         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
41967         FREE((void*)this_ptr);
41968         Type_free(this_ptr_conv);
41969 }
41970
41971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41972         LDKNodeId 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         NodeId_free(this_obj_conv);
41977 }
41978
41979 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
41980         LDKNodeId ret_var = NodeId_clone(arg);
41981 int64_t ret_ref = 0;
41982 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41983 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41984 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41985 ret_ref = (uintptr_t)ret_var.inner;
41986 if (ret_var.is_owned) {
41987         ret_ref |= 1;
41988 }
41989         return ret_ref;
41990 }
41991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41992         LDKNodeId arg_conv;
41993         arg_conv.inner = (void*)(arg & (~1));
41994         arg_conv.is_owned = false;
41995         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41996         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
41997         return ret_conv;
41998 }
41999
42000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42001         LDKNodeId orig_conv;
42002         orig_conv.inner = (void*)(orig & (~1));
42003         orig_conv.is_owned = false;
42004         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42005         LDKNodeId ret_var = NodeId_clone(&orig_conv);
42006         int64_t ret_ref = 0;
42007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42010         ret_ref = (uintptr_t)ret_var.inner;
42011         if (ret_var.is_owned) {
42012                 ret_ref |= 1;
42013         }
42014         return ret_ref;
42015 }
42016
42017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
42018         LDKPublicKey pubkey_ref;
42019         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42020         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42021         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
42022         int64_t ret_ref = 0;
42023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42026         ret_ref = (uintptr_t)ret_var.inner;
42027         if (ret_var.is_owned) {
42028                 ret_ref |= 1;
42029         }
42030         return ret_ref;
42031 }
42032
42033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
42034         LDKNodeId this_arg_conv;
42035         this_arg_conv.inner = (void*)(this_arg & (~1));
42036         this_arg_conv.is_owned = false;
42037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42038         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
42039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42041         return ret_arr;
42042 }
42043
42044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
42045         LDKNodeId o_conv;
42046         o_conv.inner = (void*)(o & (~1));
42047         o_conv.is_owned = false;
42048         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42049         int64_t ret_conv = NodeId_hash(&o_conv);
42050         return ret_conv;
42051 }
42052
42053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
42054         LDKNodeId obj_conv;
42055         obj_conv.inner = (void*)(obj & (~1));
42056         obj_conv.is_owned = false;
42057         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42058         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
42059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42061         CVec_u8Z_free(ret_var);
42062         return ret_arr;
42063 }
42064
42065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42066         LDKu8slice ser_ref;
42067         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42068         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42069         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
42070         *ret_conv = NodeId_read(ser_ref);
42071         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42072         return (int64_t)ret_conv;
42073 }
42074
42075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42076         LDKNetworkGraph this_obj_conv;
42077         this_obj_conv.inner = (void*)(this_obj & (~1));
42078         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42080         NetworkGraph_free(this_obj_conv);
42081 }
42082
42083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42084         LDKReadOnlyNetworkGraph this_obj_conv;
42085         this_obj_conv.inner = (void*)(this_obj & (~1));
42086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42088         ReadOnlyNetworkGraph_free(this_obj_conv);
42089 }
42090
42091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42092         if ((this_ptr & 1) != 0) return;
42093         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42094         CHECK_ACCESS(this_ptr_ptr);
42095         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
42096         FREE((void*)this_ptr);
42097         NetworkUpdate_free(this_ptr_conv);
42098 }
42099
42100 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
42101         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42102         *ret_copy = NetworkUpdate_clone(arg);
42103 int64_t ret_ref = (uintptr_t)ret_copy;
42104         return ret_ref;
42105 }
42106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42107         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
42108         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
42109         return ret_conv;
42110 }
42111
42112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42113         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
42114         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42115         *ret_copy = NetworkUpdate_clone(orig_conv);
42116         int64_t ret_ref = (uintptr_t)ret_copy;
42117         return ret_ref;
42118 }
42119
42120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
42121         LDKChannelUpdate msg_conv;
42122         msg_conv.inner = (void*)(msg & (~1));
42123         msg_conv.is_owned = (msg & 1) || (msg == 0);
42124         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42125         msg_conv = ChannelUpdate_clone(&msg_conv);
42126         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42127         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
42128         int64_t ret_ref = (uintptr_t)ret_copy;
42129         return ret_ref;
42130 }
42131
42132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
42133         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42134         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
42135         int64_t ret_ref = (uintptr_t)ret_copy;
42136         return ret_ref;
42137 }
42138
42139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
42140         LDKPublicKey node_id_ref;
42141         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42142         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42143         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42144         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
42145         int64_t ret_ref = (uintptr_t)ret_copy;
42146         return ret_ref;
42147 }
42148
42149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
42150         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
42151         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
42152         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42153         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42154         CVec_u8Z_free(ret_var);
42155         return ret_arr;
42156 }
42157
42158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42159         LDKu8slice ser_ref;
42160         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42161         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42162         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
42163         *ret_conv = NetworkUpdate_read(ser_ref);
42164         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42165         return (int64_t)ret_conv;
42166 }
42167
42168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42169         LDKP2PGossipSync this_obj_conv;
42170         this_obj_conv.inner = (void*)(this_obj & (~1));
42171         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42173         P2PGossipSync_free(this_obj_conv);
42174 }
42175
42176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
42177         LDKNetworkGraph network_graph_conv;
42178         network_graph_conv.inner = (void*)(network_graph & (~1));
42179         network_graph_conv.is_owned = false;
42180         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42181         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42182         CHECK_ACCESS(chain_access_ptr);
42183         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42184         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42185         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42186                 // Manually implement clone for Java trait instances
42187                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42188                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42189                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42190                 }
42191         }
42192         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42193         CHECK_ACCESS(logger_ptr);
42194         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42195         if (logger_conv.free == LDKLogger_JCalls_free) {
42196                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42197                 LDKLogger_JCalls_cloned(&logger_conv);
42198         }
42199         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
42200         int64_t ret_ref = 0;
42201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42204         ret_ref = (uintptr_t)ret_var.inner;
42205         if (ret_var.is_owned) {
42206                 ret_ref |= 1;
42207         }
42208         return ret_ref;
42209 }
42210
42211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
42212         LDKP2PGossipSync this_arg_conv;
42213         this_arg_conv.inner = (void*)(this_arg & (~1));
42214         this_arg_conv.is_owned = false;
42215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42216         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42217         CHECK_ACCESS(chain_access_ptr);
42218         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42219         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42220         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42221                 // Manually implement clone for Java trait instances
42222                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42223                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42224                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42225                 }
42226         }
42227         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
42228 }
42229
42230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42231         LDKNetworkGraph this_arg_conv;
42232         this_arg_conv.inner = (void*)(this_arg & (~1));
42233         this_arg_conv.is_owned = false;
42234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42235         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42236         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
42237         return (int64_t)ret_ret;
42238 }
42239
42240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42241         LDKP2PGossipSync this_arg_conv;
42242         this_arg_conv.inner = (void*)(this_arg & (~1));
42243         this_arg_conv.is_owned = false;
42244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42245         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
42246         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
42247         return (int64_t)ret_ret;
42248 }
42249
42250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
42251         LDKP2PGossipSync this_arg_conv;
42252         this_arg_conv.inner = (void*)(this_arg & (~1));
42253         this_arg_conv.is_owned = false;
42254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42255         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
42256         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
42257         return (int64_t)ret_ret;
42258 }
42259
42260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42261         LDKChannelUpdateInfo this_obj_conv;
42262         this_obj_conv.inner = (void*)(this_obj & (~1));
42263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42265         ChannelUpdateInfo_free(this_obj_conv);
42266 }
42267
42268 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
42269         LDKChannelUpdateInfo this_ptr_conv;
42270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42271         this_ptr_conv.is_owned = false;
42272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42273         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
42274         return ret_conv;
42275 }
42276
42277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42278         LDKChannelUpdateInfo this_ptr_conv;
42279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42280         this_ptr_conv.is_owned = false;
42281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42282         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
42283 }
42284
42285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
42286         LDKChannelUpdateInfo this_ptr_conv;
42287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42288         this_ptr_conv.is_owned = false;
42289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42290         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
42291         return ret_conv;
42292 }
42293
42294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42295         LDKChannelUpdateInfo this_ptr_conv;
42296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42297         this_ptr_conv.is_owned = false;
42298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42299         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
42300 }
42301
42302 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42303         LDKChannelUpdateInfo this_ptr_conv;
42304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42305         this_ptr_conv.is_owned = false;
42306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42307         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
42308         return ret_conv;
42309 }
42310
42311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42312         LDKChannelUpdateInfo this_ptr_conv;
42313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42314         this_ptr_conv.is_owned = false;
42315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42316         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
42317 }
42318
42319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42320         LDKChannelUpdateInfo this_ptr_conv;
42321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42322         this_ptr_conv.is_owned = false;
42323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42324         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
42325         return ret_conv;
42326 }
42327
42328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42329         LDKChannelUpdateInfo this_ptr_conv;
42330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42331         this_ptr_conv.is_owned = false;
42332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42333         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
42334 }
42335
42336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42337         LDKChannelUpdateInfo this_ptr_conv;
42338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42339         this_ptr_conv.is_owned = false;
42340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42341         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42342         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
42343         int64_t ret_ref = (uintptr_t)ret_copy;
42344         return ret_ref;
42345 }
42346
42347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42348         LDKChannelUpdateInfo this_ptr_conv;
42349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42350         this_ptr_conv.is_owned = false;
42351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42352         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42353         CHECK_ACCESS(val_ptr);
42354         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42355         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42356         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42357 }
42358
42359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42360         LDKChannelUpdateInfo this_ptr_conv;
42361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42362         this_ptr_conv.is_owned = false;
42363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42364         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
42365         int64_t ret_ref = 0;
42366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42369         ret_ref = (uintptr_t)ret_var.inner;
42370         if (ret_var.is_owned) {
42371                 ret_ref |= 1;
42372         }
42373         return ret_ref;
42374 }
42375
42376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42377         LDKChannelUpdateInfo this_ptr_conv;
42378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42379         this_ptr_conv.is_owned = false;
42380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42381         LDKRoutingFees val_conv;
42382         val_conv.inner = (void*)(val & (~1));
42383         val_conv.is_owned = (val & 1) || (val == 0);
42384         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42385         val_conv = RoutingFees_clone(&val_conv);
42386         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
42387 }
42388
42389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42390         LDKChannelUpdateInfo this_ptr_conv;
42391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42392         this_ptr_conv.is_owned = false;
42393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42394         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
42395         int64_t ret_ref = 0;
42396         if ((uintptr_t)ret_var.inner > 4096) {
42397                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42398                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42400                 ret_ref = (uintptr_t)ret_var.inner;
42401                 if (ret_var.is_owned) {
42402                         ret_ref |= 1;
42403                 }
42404         }
42405         return ret_ref;
42406 }
42407
42408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42409         LDKChannelUpdateInfo this_ptr_conv;
42410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42411         this_ptr_conv.is_owned = false;
42412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42413         LDKChannelUpdate val_conv;
42414         val_conv.inner = (void*)(val & (~1));
42415         val_conv.is_owned = (val & 1) || (val == 0);
42416         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42417         val_conv = ChannelUpdate_clone(&val_conv);
42418         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
42419 }
42420
42421 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) {
42422         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42423         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42424         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42425         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42426         LDKRoutingFees fees_arg_conv;
42427         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42428         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42429         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42430         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42431         LDKChannelUpdate last_update_message_arg_conv;
42432         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
42433         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
42434         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
42435         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
42436         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);
42437         int64_t ret_ref = 0;
42438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42441         ret_ref = (uintptr_t)ret_var.inner;
42442         if (ret_var.is_owned) {
42443                 ret_ref |= 1;
42444         }
42445         return ret_ref;
42446 }
42447
42448 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
42449         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
42450 int64_t ret_ref = 0;
42451 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42452 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42453 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42454 ret_ref = (uintptr_t)ret_var.inner;
42455 if (ret_var.is_owned) {
42456         ret_ref |= 1;
42457 }
42458         return ret_ref;
42459 }
42460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42461         LDKChannelUpdateInfo arg_conv;
42462         arg_conv.inner = (void*)(arg & (~1));
42463         arg_conv.is_owned = false;
42464         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42465         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
42466         return ret_conv;
42467 }
42468
42469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42470         LDKChannelUpdateInfo orig_conv;
42471         orig_conv.inner = (void*)(orig & (~1));
42472         orig_conv.is_owned = false;
42473         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42474         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
42475         int64_t ret_ref = 0;
42476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42479         ret_ref = (uintptr_t)ret_var.inner;
42480         if (ret_var.is_owned) {
42481                 ret_ref |= 1;
42482         }
42483         return ret_ref;
42484 }
42485
42486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42487         LDKChannelUpdateInfo obj_conv;
42488         obj_conv.inner = (void*)(obj & (~1));
42489         obj_conv.is_owned = false;
42490         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42491         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
42492         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42493         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42494         CVec_u8Z_free(ret_var);
42495         return ret_arr;
42496 }
42497
42498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42499         LDKu8slice ser_ref;
42500         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42501         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42502         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
42503         *ret_conv = ChannelUpdateInfo_read(ser_ref);
42504         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42505         return (int64_t)ret_conv;
42506 }
42507
42508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42509         LDKChannelInfo this_obj_conv;
42510         this_obj_conv.inner = (void*)(this_obj & (~1));
42511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42513         ChannelInfo_free(this_obj_conv);
42514 }
42515
42516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42517         LDKChannelInfo this_ptr_conv;
42518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42519         this_ptr_conv.is_owned = false;
42520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42521         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
42522         int64_t ret_ref = 0;
42523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42526         ret_ref = (uintptr_t)ret_var.inner;
42527         if (ret_var.is_owned) {
42528                 ret_ref |= 1;
42529         }
42530         return ret_ref;
42531 }
42532
42533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42534         LDKChannelInfo this_ptr_conv;
42535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42536         this_ptr_conv.is_owned = false;
42537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42538         LDKChannelFeatures val_conv;
42539         val_conv.inner = (void*)(val & (~1));
42540         val_conv.is_owned = (val & 1) || (val == 0);
42541         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42542         val_conv = ChannelFeatures_clone(&val_conv);
42543         ChannelInfo_set_features(&this_ptr_conv, val_conv);
42544 }
42545
42546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
42547         LDKChannelInfo this_ptr_conv;
42548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42549         this_ptr_conv.is_owned = false;
42550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42551         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
42552         int64_t ret_ref = 0;
42553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42556         ret_ref = (uintptr_t)ret_var.inner;
42557         if (ret_var.is_owned) {
42558                 ret_ref |= 1;
42559         }
42560         return ret_ref;
42561 }
42562
42563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42564         LDKChannelInfo this_ptr_conv;
42565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42566         this_ptr_conv.is_owned = false;
42567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42568         LDKNodeId val_conv;
42569         val_conv.inner = (void*)(val & (~1));
42570         val_conv.is_owned = (val & 1) || (val == 0);
42571         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42572         val_conv = NodeId_clone(&val_conv);
42573         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
42574 }
42575
42576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
42577         LDKChannelInfo this_ptr_conv;
42578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42579         this_ptr_conv.is_owned = false;
42580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42581         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
42582         int64_t ret_ref = 0;
42583         if ((uintptr_t)ret_var.inner > 4096) {
42584                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42585                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42587                 ret_ref = (uintptr_t)ret_var.inner;
42588                 if (ret_var.is_owned) {
42589                         ret_ref |= 1;
42590                 }
42591         }
42592         return ret_ref;
42593 }
42594
42595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42596         LDKChannelInfo this_ptr_conv;
42597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42598         this_ptr_conv.is_owned = false;
42599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42600         LDKChannelUpdateInfo val_conv;
42601         val_conv.inner = (void*)(val & (~1));
42602         val_conv.is_owned = (val & 1) || (val == 0);
42603         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42604         val_conv = ChannelUpdateInfo_clone(&val_conv);
42605         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
42606 }
42607
42608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
42609         LDKChannelInfo 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         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
42614         int64_t ret_ref = 0;
42615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42618         ret_ref = (uintptr_t)ret_var.inner;
42619         if (ret_var.is_owned) {
42620                 ret_ref |= 1;
42621         }
42622         return ret_ref;
42623 }
42624
42625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42626         LDKChannelInfo this_ptr_conv;
42627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42628         this_ptr_conv.is_owned = false;
42629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42630         LDKNodeId val_conv;
42631         val_conv.inner = (void*)(val & (~1));
42632         val_conv.is_owned = (val & 1) || (val == 0);
42633         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42634         val_conv = NodeId_clone(&val_conv);
42635         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
42636 }
42637
42638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
42639         LDKChannelInfo 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         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
42644         int64_t ret_ref = 0;
42645         if ((uintptr_t)ret_var.inner > 4096) {
42646                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42647                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42649                 ret_ref = (uintptr_t)ret_var.inner;
42650                 if (ret_var.is_owned) {
42651                         ret_ref |= 1;
42652                 }
42653         }
42654         return ret_ref;
42655 }
42656
42657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42658         LDKChannelInfo this_ptr_conv;
42659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42660         this_ptr_conv.is_owned = false;
42661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42662         LDKChannelUpdateInfo val_conv;
42663         val_conv.inner = (void*)(val & (~1));
42664         val_conv.is_owned = (val & 1) || (val == 0);
42665         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42666         val_conv = ChannelUpdateInfo_clone(&val_conv);
42667         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
42668 }
42669
42670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
42671         LDKChannelInfo this_ptr_conv;
42672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42673         this_ptr_conv.is_owned = false;
42674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42675         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42676         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
42677         int64_t ret_ref = (uintptr_t)ret_copy;
42678         return ret_ref;
42679 }
42680
42681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42682         LDKChannelInfo this_ptr_conv;
42683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42684         this_ptr_conv.is_owned = false;
42685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42686         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42687         CHECK_ACCESS(val_ptr);
42688         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42689         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42690         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
42691 }
42692
42693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42694         LDKChannelInfo 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         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
42699         int64_t ret_ref = 0;
42700         if ((uintptr_t)ret_var.inner > 4096) {
42701                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42702                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42704                 ret_ref = (uintptr_t)ret_var.inner;
42705                 if (ret_var.is_owned) {
42706                         ret_ref |= 1;
42707                 }
42708         }
42709         return ret_ref;
42710 }
42711
42712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42713         LDKChannelInfo this_ptr_conv;
42714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42715         this_ptr_conv.is_owned = false;
42716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42717         LDKChannelAnnouncement val_conv;
42718         val_conv.inner = (void*)(val & (~1));
42719         val_conv.is_owned = (val & 1) || (val == 0);
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42721         val_conv = ChannelAnnouncement_clone(&val_conv);
42722         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
42723 }
42724
42725 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
42726         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
42727 int64_t ret_ref = 0;
42728 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42729 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42730 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42731 ret_ref = (uintptr_t)ret_var.inner;
42732 if (ret_var.is_owned) {
42733         ret_ref |= 1;
42734 }
42735         return ret_ref;
42736 }
42737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42738         LDKChannelInfo arg_conv;
42739         arg_conv.inner = (void*)(arg & (~1));
42740         arg_conv.is_owned = false;
42741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42742         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
42743         return ret_conv;
42744 }
42745
42746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42747         LDKChannelInfo orig_conv;
42748         orig_conv.inner = (void*)(orig & (~1));
42749         orig_conv.is_owned = false;
42750         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42751         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
42752         int64_t ret_ref = 0;
42753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42756         ret_ref = (uintptr_t)ret_var.inner;
42757         if (ret_var.is_owned) {
42758                 ret_ref |= 1;
42759         }
42760         return ret_ref;
42761 }
42762
42763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1directional_1info(JNIEnv *env, jclass clz, int64_t this_arg, int8_t channel_flags) {
42764         LDKChannelInfo this_arg_conv;
42765         this_arg_conv.inner = (void*)(this_arg & (~1));
42766         this_arg_conv.is_owned = false;
42767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42768         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
42769         int64_t ret_ref = 0;
42770         if ((uintptr_t)ret_var.inner > 4096) {
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         }
42779         return ret_ref;
42780 }
42781
42782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42783         LDKChannelInfo obj_conv;
42784         obj_conv.inner = (void*)(obj & (~1));
42785         obj_conv.is_owned = false;
42786         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42787         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
42788         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42789         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42790         CVec_u8Z_free(ret_var);
42791         return ret_arr;
42792 }
42793
42794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42795         LDKu8slice ser_ref;
42796         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42797         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42798         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
42799         *ret_conv = ChannelInfo_read(ser_ref);
42800         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42801         return (int64_t)ret_conv;
42802 }
42803
42804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42805         LDKDirectedChannelInfo this_obj_conv;
42806         this_obj_conv.inner = (void*)(this_obj & (~1));
42807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42809         DirectedChannelInfo_free(this_obj_conv);
42810 }
42811
42812 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
42813         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
42814 int64_t ret_ref = 0;
42815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42818 ret_ref = (uintptr_t)ret_var.inner;
42819 if (ret_var.is_owned) {
42820         ret_ref |= 1;
42821 }
42822         return ret_ref;
42823 }
42824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42825         LDKDirectedChannelInfo arg_conv;
42826         arg_conv.inner = (void*)(arg & (~1));
42827         arg_conv.is_owned = false;
42828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42829         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
42830         return ret_conv;
42831 }
42832
42833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42834         LDKDirectedChannelInfo orig_conv;
42835         orig_conv.inner = (void*)(orig & (~1));
42836         orig_conv.is_owned = false;
42837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42838         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
42839         int64_t ret_ref = 0;
42840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42843         ret_ref = (uintptr_t)ret_var.inner;
42844         if (ret_var.is_owned) {
42845                 ret_ref |= 1;
42846         }
42847         return ret_ref;
42848 }
42849
42850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
42851         LDKDirectedChannelInfo this_arg_conv;
42852         this_arg_conv.inner = (void*)(this_arg & (~1));
42853         this_arg_conv.is_owned = false;
42854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42855         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
42856         int64_t ret_ref = 0;
42857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42860         ret_ref = (uintptr_t)ret_var.inner;
42861         if (ret_var.is_owned) {
42862                 ret_ref |= 1;
42863         }
42864         return ret_ref;
42865 }
42866
42867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
42868         LDKDirectedChannelInfo this_arg_conv;
42869         this_arg_conv.inner = (void*)(this_arg & (~1));
42870         this_arg_conv.is_owned = false;
42871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42872         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
42873         int64_t ret_ref = 0;
42874         if ((uintptr_t)ret_var.inner > 4096) {
42875                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42876                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42878                 ret_ref = (uintptr_t)ret_var.inner;
42879                 if (ret_var.is_owned) {
42880                         ret_ref |= 1;
42881                 }
42882         }
42883         return ret_ref;
42884 }
42885
42886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42887         LDKDirectedChannelInfo this_arg_conv;
42888         this_arg_conv.inner = (void*)(this_arg & (~1));
42889         this_arg_conv.is_owned = false;
42890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42891         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
42892         return ret_conv;
42893 }
42894
42895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
42896         LDKDirectedChannelInfo this_arg_conv;
42897         this_arg_conv.inner = (void*)(this_arg & (~1));
42898         this_arg_conv.is_owned = false;
42899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42900         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42901         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
42902         int64_t ret_ref = (uintptr_t)ret_copy;
42903         return ret_ref;
42904 }
42905
42906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42907         if ((this_ptr & 1) != 0) return;
42908         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42909         CHECK_ACCESS(this_ptr_ptr);
42910         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
42911         FREE((void*)this_ptr);
42912         EffectiveCapacity_free(this_ptr_conv);
42913 }
42914
42915 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
42916         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42917         *ret_copy = EffectiveCapacity_clone(arg);
42918 int64_t ret_ref = (uintptr_t)ret_copy;
42919         return ret_ref;
42920 }
42921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42922         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
42923         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
42924         return ret_conv;
42925 }
42926
42927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42928         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
42929         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42930         *ret_copy = EffectiveCapacity_clone(orig_conv);
42931         int64_t ret_ref = (uintptr_t)ret_copy;
42932         return ret_ref;
42933 }
42934
42935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
42936         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42937         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
42938         int64_t ret_ref = (uintptr_t)ret_copy;
42939         return ret_ref;
42940 }
42941
42942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
42943         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42944         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
42945         int64_t ret_ref = (uintptr_t)ret_copy;
42946         return ret_ref;
42947 }
42948
42949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
42950         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
42951         CHECK_ACCESS(htlc_maximum_msat_ptr);
42952         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
42953         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
42954         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42955         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
42956         int64_t ret_ref = (uintptr_t)ret_copy;
42957         return ret_ref;
42958 }
42959
42960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
42961         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42962         *ret_copy = EffectiveCapacity_infinite();
42963         int64_t ret_ref = (uintptr_t)ret_copy;
42964         return ret_ref;
42965 }
42966
42967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
42968         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42969         *ret_copy = EffectiveCapacity_unknown();
42970         int64_t ret_ref = (uintptr_t)ret_copy;
42971         return ret_ref;
42972 }
42973
42974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42975         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
42976         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
42977         return ret_conv;
42978 }
42979
42980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42981         LDKRoutingFees this_obj_conv;
42982         this_obj_conv.inner = (void*)(this_obj & (~1));
42983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42985         RoutingFees_free(this_obj_conv);
42986 }
42987
42988 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42989         LDKRoutingFees this_ptr_conv;
42990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42991         this_ptr_conv.is_owned = false;
42992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42993         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
42994         return ret_conv;
42995 }
42996
42997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42998         LDKRoutingFees this_ptr_conv;
42999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43000         this_ptr_conv.is_owned = false;
43001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43002         RoutingFees_set_base_msat(&this_ptr_conv, val);
43003 }
43004
43005 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43006         LDKRoutingFees this_ptr_conv;
43007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43008         this_ptr_conv.is_owned = false;
43009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43010         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
43011         return ret_conv;
43012 }
43013
43014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43015         LDKRoutingFees this_ptr_conv;
43016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43017         this_ptr_conv.is_owned = false;
43018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43019         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
43020 }
43021
43022 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) {
43023         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
43024         int64_t ret_ref = 0;
43025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43028         ret_ref = (uintptr_t)ret_var.inner;
43029         if (ret_var.is_owned) {
43030                 ret_ref |= 1;
43031         }
43032         return ret_ref;
43033 }
43034
43035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43036         LDKRoutingFees a_conv;
43037         a_conv.inner = (void*)(a & (~1));
43038         a_conv.is_owned = false;
43039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43040         LDKRoutingFees b_conv;
43041         b_conv.inner = (void*)(b & (~1));
43042         b_conv.is_owned = false;
43043         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43044         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
43045         return ret_conv;
43046 }
43047
43048 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
43049         LDKRoutingFees ret_var = RoutingFees_clone(arg);
43050 int64_t ret_ref = 0;
43051 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43052 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43053 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43054 ret_ref = (uintptr_t)ret_var.inner;
43055 if (ret_var.is_owned) {
43056         ret_ref |= 1;
43057 }
43058         return ret_ref;
43059 }
43060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43061         LDKRoutingFees arg_conv;
43062         arg_conv.inner = (void*)(arg & (~1));
43063         arg_conv.is_owned = false;
43064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43065         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
43066         return ret_conv;
43067 }
43068
43069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43070         LDKRoutingFees orig_conv;
43071         orig_conv.inner = (void*)(orig & (~1));
43072         orig_conv.is_owned = false;
43073         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43074         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
43075         int64_t ret_ref = 0;
43076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43079         ret_ref = (uintptr_t)ret_var.inner;
43080         if (ret_var.is_owned) {
43081                 ret_ref |= 1;
43082         }
43083         return ret_ref;
43084 }
43085
43086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
43087         LDKRoutingFees o_conv;
43088         o_conv.inner = (void*)(o & (~1));
43089         o_conv.is_owned = false;
43090         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43091         int64_t ret_conv = RoutingFees_hash(&o_conv);
43092         return ret_conv;
43093 }
43094
43095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
43096         LDKRoutingFees obj_conv;
43097         obj_conv.inner = (void*)(obj & (~1));
43098         obj_conv.is_owned = false;
43099         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43100         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
43101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43103         CVec_u8Z_free(ret_var);
43104         return ret_arr;
43105 }
43106
43107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43108         LDKu8slice ser_ref;
43109         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43110         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43111         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
43112         *ret_conv = RoutingFees_read(ser_ref);
43113         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43114         return (int64_t)ret_conv;
43115 }
43116
43117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43118         LDKNodeAnnouncementInfo this_obj_conv;
43119         this_obj_conv.inner = (void*)(this_obj & (~1));
43120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43122         NodeAnnouncementInfo_free(this_obj_conv);
43123 }
43124
43125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43126         LDKNodeAnnouncementInfo this_ptr_conv;
43127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43128         this_ptr_conv.is_owned = false;
43129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43130         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
43131         int64_t ret_ref = 0;
43132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43135         ret_ref = (uintptr_t)ret_var.inner;
43136         if (ret_var.is_owned) {
43137                 ret_ref |= 1;
43138         }
43139         return ret_ref;
43140 }
43141
43142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43143         LDKNodeAnnouncementInfo this_ptr_conv;
43144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43145         this_ptr_conv.is_owned = false;
43146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43147         LDKNodeFeatures val_conv;
43148         val_conv.inner = (void*)(val & (~1));
43149         val_conv.is_owned = (val & 1) || (val == 0);
43150         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43151         val_conv = NodeFeatures_clone(&val_conv);
43152         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
43153 }
43154
43155 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43156         LDKNodeAnnouncementInfo this_ptr_conv;
43157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43158         this_ptr_conv.is_owned = false;
43159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43160         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
43161         return ret_conv;
43162 }
43163
43164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43165         LDKNodeAnnouncementInfo this_ptr_conv;
43166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43167         this_ptr_conv.is_owned = false;
43168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43169         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
43170 }
43171
43172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
43173         LDKNodeAnnouncementInfo this_ptr_conv;
43174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43175         this_ptr_conv.is_owned = false;
43176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43177         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
43178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
43179         return ret_arr;
43180 }
43181
43182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43183         LDKNodeAnnouncementInfo this_ptr_conv;
43184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43185         this_ptr_conv.is_owned = false;
43186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43187         LDKThreeBytes val_ref;
43188         CHECK((*env)->GetArrayLength(env, val) == 3);
43189         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
43190         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
43191 }
43192
43193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
43194         LDKNodeAnnouncementInfo this_ptr_conv;
43195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43196         this_ptr_conv.is_owned = false;
43197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43198         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
43199         int64_t ret_ref = 0;
43200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43203         ret_ref = (uintptr_t)ret_var.inner;
43204         if (ret_var.is_owned) {
43205                 ret_ref |= 1;
43206         }
43207         return ret_ref;
43208 }
43209
43210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43211         LDKNodeAnnouncementInfo this_ptr_conv;
43212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43213         this_ptr_conv.is_owned = false;
43214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43215         LDKNodeAlias val_conv;
43216         val_conv.inner = (void*)(val & (~1));
43217         val_conv.is_owned = (val & 1) || (val == 0);
43218         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43219         val_conv = NodeAlias_clone(&val_conv);
43220         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
43221 }
43222
43223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43224         LDKNodeAnnouncementInfo this_ptr_conv;
43225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43226         this_ptr_conv.is_owned = false;
43227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43228         LDKCVec_NetAddressZ val_constr;
43229         val_constr.datalen = (*env)->GetArrayLength(env, val);
43230         if (val_constr.datalen > 0)
43231                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
43232         else
43233                 val_constr.data = NULL;
43234         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43235         for (size_t m = 0; m < val_constr.datalen; m++) {
43236                 int64_t val_conv_12 = val_vals[m];
43237                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
43238                 CHECK_ACCESS(val_conv_12_ptr);
43239                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
43240                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
43241                 val_constr.data[m] = val_conv_12_conv;
43242         }
43243         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43244         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
43245 }
43246
43247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43248         LDKNodeAnnouncementInfo this_ptr_conv;
43249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43250         this_ptr_conv.is_owned = false;
43251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43252         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
43253         int64_t ret_ref = 0;
43254         if ((uintptr_t)ret_var.inner > 4096) {
43255                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43256                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43258                 ret_ref = (uintptr_t)ret_var.inner;
43259                 if (ret_var.is_owned) {
43260                         ret_ref |= 1;
43261                 }
43262         }
43263         return ret_ref;
43264 }
43265
43266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43267         LDKNodeAnnouncementInfo this_ptr_conv;
43268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43269         this_ptr_conv.is_owned = false;
43270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43271         LDKNodeAnnouncement val_conv;
43272         val_conv.inner = (void*)(val & (~1));
43273         val_conv.is_owned = (val & 1) || (val == 0);
43274         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43275         val_conv = NodeAnnouncement_clone(&val_conv);
43276         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
43277 }
43278
43279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
43280         LDKNodeFeatures features_arg_conv;
43281         features_arg_conv.inner = (void*)(features_arg & (~1));
43282         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
43283         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
43284         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
43285         LDKThreeBytes rgb_arg_ref;
43286         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
43287         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
43288         LDKNodeAlias alias_arg_conv;
43289         alias_arg_conv.inner = (void*)(alias_arg & (~1));
43290         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
43291         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
43292         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
43293         LDKCVec_NetAddressZ addresses_arg_constr;
43294         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
43295         if (addresses_arg_constr.datalen > 0)
43296                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
43297         else
43298                 addresses_arg_constr.data = NULL;
43299         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
43300         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
43301                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
43302                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
43303                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
43304                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
43305                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
43306         }
43307         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
43308         LDKNodeAnnouncement announcement_message_arg_conv;
43309         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
43310         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
43311         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
43312         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
43313         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
43314         int64_t ret_ref = 0;
43315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43318         ret_ref = (uintptr_t)ret_var.inner;
43319         if (ret_var.is_owned) {
43320                 ret_ref |= 1;
43321         }
43322         return ret_ref;
43323 }
43324
43325 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
43326         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
43327 int64_t ret_ref = 0;
43328 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43329 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43330 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43331 ret_ref = (uintptr_t)ret_var.inner;
43332 if (ret_var.is_owned) {
43333         ret_ref |= 1;
43334 }
43335         return ret_ref;
43336 }
43337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43338         LDKNodeAnnouncementInfo arg_conv;
43339         arg_conv.inner = (void*)(arg & (~1));
43340         arg_conv.is_owned = false;
43341         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43342         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
43343         return ret_conv;
43344 }
43345
43346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43347         LDKNodeAnnouncementInfo orig_conv;
43348         orig_conv.inner = (void*)(orig & (~1));
43349         orig_conv.is_owned = false;
43350         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43351         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
43352         int64_t ret_ref = 0;
43353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43356         ret_ref = (uintptr_t)ret_var.inner;
43357         if (ret_var.is_owned) {
43358                 ret_ref |= 1;
43359         }
43360         return ret_ref;
43361 }
43362
43363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43364         LDKNodeAnnouncementInfo obj_conv;
43365         obj_conv.inner = (void*)(obj & (~1));
43366         obj_conv.is_owned = false;
43367         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43368         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
43369         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43370         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43371         CVec_u8Z_free(ret_var);
43372         return ret_arr;
43373 }
43374
43375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43376         LDKu8slice ser_ref;
43377         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43378         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43379         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
43380         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
43381         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43382         return (int64_t)ret_conv;
43383 }
43384
43385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43386         LDKNodeAlias this_obj_conv;
43387         this_obj_conv.inner = (void*)(this_obj & (~1));
43388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43390         NodeAlias_free(this_obj_conv);
43391 }
43392
43393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
43394         LDKNodeAlias this_ptr_conv;
43395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43396         this_ptr_conv.is_owned = false;
43397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43398         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43399         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
43400         return ret_arr;
43401 }
43402
43403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43404         LDKNodeAlias this_ptr_conv;
43405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43406         this_ptr_conv.is_owned = false;
43407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43408         LDKThirtyTwoBytes val_ref;
43409         CHECK((*env)->GetArrayLength(env, val) == 32);
43410         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43411         NodeAlias_set_a(&this_ptr_conv, val_ref);
43412 }
43413
43414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
43415         LDKThirtyTwoBytes a_arg_ref;
43416         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
43417         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
43418         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
43419         int64_t ret_ref = 0;
43420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43423         ret_ref = (uintptr_t)ret_var.inner;
43424         if (ret_var.is_owned) {
43425                 ret_ref |= 1;
43426         }
43427         return ret_ref;
43428 }
43429
43430 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
43431         LDKNodeAlias ret_var = NodeAlias_clone(arg);
43432 int64_t ret_ref = 0;
43433 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43434 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43435 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43436 ret_ref = (uintptr_t)ret_var.inner;
43437 if (ret_var.is_owned) {
43438         ret_ref |= 1;
43439 }
43440         return ret_ref;
43441 }
43442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43443         LDKNodeAlias arg_conv;
43444         arg_conv.inner = (void*)(arg & (~1));
43445         arg_conv.is_owned = false;
43446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43447         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
43448         return ret_conv;
43449 }
43450
43451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43452         LDKNodeAlias orig_conv;
43453         orig_conv.inner = (void*)(orig & (~1));
43454         orig_conv.is_owned = false;
43455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43456         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
43457         int64_t ret_ref = 0;
43458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43461         ret_ref = (uintptr_t)ret_var.inner;
43462         if (ret_var.is_owned) {
43463                 ret_ref |= 1;
43464         }
43465         return ret_ref;
43466 }
43467
43468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
43469         LDKNodeAlias obj_conv;
43470         obj_conv.inner = (void*)(obj & (~1));
43471         obj_conv.is_owned = false;
43472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43473         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
43474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43476         CVec_u8Z_free(ret_var);
43477         return ret_arr;
43478 }
43479
43480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43481         LDKu8slice ser_ref;
43482         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43483         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43484         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
43485         *ret_conv = NodeAlias_read(ser_ref);
43486         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43487         return (int64_t)ret_conv;
43488 }
43489
43490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43491         LDKNodeInfo this_obj_conv;
43492         this_obj_conv.inner = (void*)(this_obj & (~1));
43493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43495         NodeInfo_free(this_obj_conv);
43496 }
43497
43498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43499         LDKNodeInfo this_ptr_conv;
43500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43501         this_ptr_conv.is_owned = false;
43502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43503         LDKCVec_u64Z val_constr;
43504         val_constr.datalen = (*env)->GetArrayLength(env, val);
43505         if (val_constr.datalen > 0)
43506                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43507         else
43508                 val_constr.data = NULL;
43509         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43510         for (size_t g = 0; g < val_constr.datalen; g++) {
43511                 int64_t val_conv_6 = val_vals[g];
43512                 val_constr.data[g] = val_conv_6;
43513         }
43514         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43515         NodeInfo_set_channels(&this_ptr_conv, val_constr);
43516 }
43517
43518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43519         LDKNodeInfo this_ptr_conv;
43520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43521         this_ptr_conv.is_owned = false;
43522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43523         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
43524         int64_t ret_ref = 0;
43525         if ((uintptr_t)ret_var.inner > 4096) {
43526                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43527                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43529                 ret_ref = (uintptr_t)ret_var.inner;
43530                 if (ret_var.is_owned) {
43531                         ret_ref |= 1;
43532                 }
43533         }
43534         return ret_ref;
43535 }
43536
43537 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) {
43538         LDKNodeInfo this_ptr_conv;
43539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43540         this_ptr_conv.is_owned = false;
43541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43542         LDKRoutingFees val_conv;
43543         val_conv.inner = (void*)(val & (~1));
43544         val_conv.is_owned = (val & 1) || (val == 0);
43545         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43546         val_conv = RoutingFees_clone(&val_conv);
43547         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
43548 }
43549
43550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
43551         LDKNodeInfo this_ptr_conv;
43552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43553         this_ptr_conv.is_owned = false;
43554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43555         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
43556         int64_t ret_ref = 0;
43557         if ((uintptr_t)ret_var.inner > 4096) {
43558                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43559                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43561                 ret_ref = (uintptr_t)ret_var.inner;
43562                 if (ret_var.is_owned) {
43563                         ret_ref |= 1;
43564                 }
43565         }
43566         return ret_ref;
43567 }
43568
43569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43570         LDKNodeInfo this_ptr_conv;
43571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43572         this_ptr_conv.is_owned = false;
43573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43574         LDKNodeAnnouncementInfo val_conv;
43575         val_conv.inner = (void*)(val & (~1));
43576         val_conv.is_owned = (val & 1) || (val == 0);
43577         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43578         val_conv = NodeAnnouncementInfo_clone(&val_conv);
43579         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
43580 }
43581
43582 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) {
43583         LDKCVec_u64Z channels_arg_constr;
43584         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
43585         if (channels_arg_constr.datalen > 0)
43586                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43587         else
43588                 channels_arg_constr.data = NULL;
43589         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
43590         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
43591                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
43592                 channels_arg_constr.data[g] = channels_arg_conv_6;
43593         }
43594         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
43595         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
43596         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
43597         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
43598         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
43599         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
43600         LDKNodeAnnouncementInfo announcement_info_arg_conv;
43601         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
43602         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
43603         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
43604         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
43605         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
43606         int64_t ret_ref = 0;
43607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43610         ret_ref = (uintptr_t)ret_var.inner;
43611         if (ret_var.is_owned) {
43612                 ret_ref |= 1;
43613         }
43614         return ret_ref;
43615 }
43616
43617 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
43618         LDKNodeInfo ret_var = NodeInfo_clone(arg);
43619 int64_t ret_ref = 0;
43620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43623 ret_ref = (uintptr_t)ret_var.inner;
43624 if (ret_var.is_owned) {
43625         ret_ref |= 1;
43626 }
43627         return ret_ref;
43628 }
43629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43630         LDKNodeInfo arg_conv;
43631         arg_conv.inner = (void*)(arg & (~1));
43632         arg_conv.is_owned = false;
43633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43634         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
43635         return ret_conv;
43636 }
43637
43638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43639         LDKNodeInfo orig_conv;
43640         orig_conv.inner = (void*)(orig & (~1));
43641         orig_conv.is_owned = false;
43642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43643         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
43644         int64_t ret_ref = 0;
43645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43648         ret_ref = (uintptr_t)ret_var.inner;
43649         if (ret_var.is_owned) {
43650                 ret_ref |= 1;
43651         }
43652         return ret_ref;
43653 }
43654
43655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43656         LDKNodeInfo obj_conv;
43657         obj_conv.inner = (void*)(obj & (~1));
43658         obj_conv.is_owned = false;
43659         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43660         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
43661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43663         CVec_u8Z_free(ret_var);
43664         return ret_arr;
43665 }
43666
43667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43668         LDKu8slice ser_ref;
43669         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43670         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43671         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
43672         *ret_conv = NodeInfo_read(ser_ref);
43673         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43674         return (int64_t)ret_conv;
43675 }
43676
43677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
43678         LDKNetworkGraph obj_conv;
43679         obj_conv.inner = (void*)(obj & (~1));
43680         obj_conv.is_owned = false;
43681         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43682         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
43683         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43684         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43685         CVec_u8Z_free(ret_var);
43686         return ret_arr;
43687 }
43688
43689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
43690         LDKu8slice ser_ref;
43691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43693         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
43694         CHECK_ACCESS(arg_ptr);
43695         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
43696         if (arg_conv.free == LDKLogger_JCalls_free) {
43697                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43698                 LDKLogger_JCalls_cloned(&arg_conv);
43699         }
43700         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
43701         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
43702         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43703         return (int64_t)ret_conv;
43704 }
43705
43706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
43707         LDKThirtyTwoBytes genesis_hash_ref;
43708         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
43709         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
43710         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43711         CHECK_ACCESS(logger_ptr);
43712         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43713         if (logger_conv.free == LDKLogger_JCalls_free) {
43714                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43715                 LDKLogger_JCalls_cloned(&logger_conv);
43716         }
43717         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
43718         int64_t ret_ref = 0;
43719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43722         ret_ref = (uintptr_t)ret_var.inner;
43723         if (ret_var.is_owned) {
43724                 ret_ref |= 1;
43725         }
43726         return ret_ref;
43727 }
43728
43729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
43730         LDKNetworkGraph this_arg_conv;
43731         this_arg_conv.inner = (void*)(this_arg & (~1));
43732         this_arg_conv.is_owned = false;
43733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43734         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
43735         int64_t ret_ref = 0;
43736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43739         ret_ref = (uintptr_t)ret_var.inner;
43740         if (ret_var.is_owned) {
43741                 ret_ref |= 1;
43742         }
43743         return ret_ref;
43744 }
43745
43746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
43747         LDKNetworkGraph this_arg_conv;
43748         this_arg_conv.inner = (void*)(this_arg & (~1));
43749         this_arg_conv.is_owned = false;
43750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43751         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
43752         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
43753         int64_t ret_ref = (uintptr_t)ret_copy;
43754         return ret_ref;
43755 }
43756
43757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1set_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
43758         LDKNetworkGraph this_arg_conv;
43759         this_arg_conv.inner = (void*)(this_arg & (~1));
43760         this_arg_conv.is_owned = false;
43761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43762         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
43763 }
43764
43765 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) {
43766         LDKNetworkGraph this_arg_conv;
43767         this_arg_conv.inner = (void*)(this_arg & (~1));
43768         this_arg_conv.is_owned = false;
43769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43770         LDKNodeAnnouncement msg_conv;
43771         msg_conv.inner = (void*)(msg & (~1));
43772         msg_conv.is_owned = false;
43773         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43774         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43775         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
43776         return (int64_t)ret_conv;
43777 }
43778
43779 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) {
43780         LDKNetworkGraph this_arg_conv;
43781         this_arg_conv.inner = (void*)(this_arg & (~1));
43782         this_arg_conv.is_owned = false;
43783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43784         LDKUnsignedNodeAnnouncement msg_conv;
43785         msg_conv.inner = (void*)(msg & (~1));
43786         msg_conv.is_owned = false;
43787         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43788         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43789         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
43790         return (int64_t)ret_conv;
43791 }
43792
43793 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) {
43794         LDKNetworkGraph this_arg_conv;
43795         this_arg_conv.inner = (void*)(this_arg & (~1));
43796         this_arg_conv.is_owned = false;
43797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43798         LDKChannelAnnouncement msg_conv;
43799         msg_conv.inner = (void*)(msg & (~1));
43800         msg_conv.is_owned = false;
43801         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43802         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43803         CHECK_ACCESS(chain_access_ptr);
43804         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43805         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43806         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43807                 // Manually implement clone for Java trait instances
43808                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43809                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43810                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43811                 }
43812         }
43813         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43814         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
43815         return (int64_t)ret_conv;
43816 }
43817
43818 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) {
43819         LDKNetworkGraph this_arg_conv;
43820         this_arg_conv.inner = (void*)(this_arg & (~1));
43821         this_arg_conv.is_owned = false;
43822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43823         LDKUnsignedChannelAnnouncement msg_conv;
43824         msg_conv.inner = (void*)(msg & (~1));
43825         msg_conv.is_owned = false;
43826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43827         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43828         CHECK_ACCESS(chain_access_ptr);
43829         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43830         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43831         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43832                 // Manually implement clone for Java trait instances
43833                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43834                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43835                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43836                 }
43837         }
43838         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43839         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
43840         return (int64_t)ret_conv;
43841 }
43842
43843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1add_1channel_1from_1partial_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
43844         LDKNetworkGraph this_arg_conv;
43845         this_arg_conv.inner = (void*)(this_arg & (~1));
43846         this_arg_conv.is_owned = false;
43847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43848         LDKChannelFeatures features_conv;
43849         features_conv.inner = (void*)(features & (~1));
43850         features_conv.is_owned = (features & 1) || (features == 0);
43851         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
43852         features_conv = ChannelFeatures_clone(&features_conv);
43853         LDKPublicKey node_id_1_ref;
43854         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
43855         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
43856         LDKPublicKey node_id_2_ref;
43857         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
43858         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
43859         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43860         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
43861         return (int64_t)ret_conv;
43862 }
43863
43864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
43865         LDKNetworkGraph this_arg_conv;
43866         this_arg_conv.inner = (void*)(this_arg & (~1));
43867         this_arg_conv.is_owned = false;
43868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43869         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
43870 }
43871
43872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
43873         LDKNetworkGraph this_arg_conv;
43874         this_arg_conv.inner = (void*)(this_arg & (~1));
43875         this_arg_conv.is_owned = false;
43876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43877         LDKPublicKey _node_id_ref;
43878         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
43879         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
43880         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
43881 }
43882
43883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
43884         LDKNetworkGraph this_arg_conv;
43885         this_arg_conv.inner = (void*)(this_arg & (~1));
43886         this_arg_conv.is_owned = false;
43887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43888         NetworkGraph_remove_stale_channels(&this_arg_conv);
43889 }
43890
43891 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) {
43892         LDKNetworkGraph this_arg_conv;
43893         this_arg_conv.inner = (void*)(this_arg & (~1));
43894         this_arg_conv.is_owned = false;
43895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43896         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
43897 }
43898
43899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43900         LDKNetworkGraph this_arg_conv;
43901         this_arg_conv.inner = (void*)(this_arg & (~1));
43902         this_arg_conv.is_owned = false;
43903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43904         LDKChannelUpdate msg_conv;
43905         msg_conv.inner = (void*)(msg & (~1));
43906         msg_conv.is_owned = false;
43907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43908         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43909         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
43910         return (int64_t)ret_conv;
43911 }
43912
43913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43914         LDKNetworkGraph this_arg_conv;
43915         this_arg_conv.inner = (void*)(this_arg & (~1));
43916         this_arg_conv.is_owned = false;
43917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43918         LDKUnsignedChannelUpdate msg_conv;
43919         msg_conv.inner = (void*)(msg & (~1));
43920         msg_conv.is_owned = false;
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43922         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43923         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
43924         return (int64_t)ret_conv;
43925 }
43926
43927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
43928         LDKReadOnlyNetworkGraph this_arg_conv;
43929         this_arg_conv.inner = (void*)(this_arg & (~1));
43930         this_arg_conv.is_owned = false;
43931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43932         LDKPublicKey pubkey_ref;
43933         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
43934         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
43935         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
43936         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
43937         int64_t ret_ref = (uintptr_t)ret_copy;
43938         return ret_ref;
43939 }
43940
43941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43942         LDKRouteHop 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         RouteHop_free(this_obj_conv);
43947 }
43948
43949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
43950         LDKRouteHop this_ptr_conv;
43951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43952         this_ptr_conv.is_owned = false;
43953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43954         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
43956         return ret_arr;
43957 }
43958
43959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43960         LDKRouteHop this_ptr_conv;
43961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43962         this_ptr_conv.is_owned = false;
43963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43964         LDKPublicKey val_ref;
43965         CHECK((*env)->GetArrayLength(env, val) == 33);
43966         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43967         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
43968 }
43969
43970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43971         LDKRouteHop this_ptr_conv;
43972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43973         this_ptr_conv.is_owned = false;
43974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43975         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
43976         int64_t ret_ref = 0;
43977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43980         ret_ref = (uintptr_t)ret_var.inner;
43981         if (ret_var.is_owned) {
43982                 ret_ref |= 1;
43983         }
43984         return ret_ref;
43985 }
43986
43987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43988         LDKRouteHop this_ptr_conv;
43989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43990         this_ptr_conv.is_owned = false;
43991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43992         LDKNodeFeatures val_conv;
43993         val_conv.inner = (void*)(val & (~1));
43994         val_conv.is_owned = (val & 1) || (val == 0);
43995         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43996         val_conv = NodeFeatures_clone(&val_conv);
43997         RouteHop_set_node_features(&this_ptr_conv, val_conv);
43998 }
43999
44000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44001         LDKRouteHop this_ptr_conv;
44002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44003         this_ptr_conv.is_owned = false;
44004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44005         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
44006         return ret_conv;
44007 }
44008
44009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44010         LDKRouteHop this_ptr_conv;
44011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44012         this_ptr_conv.is_owned = false;
44013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44014         RouteHop_set_short_channel_id(&this_ptr_conv, val);
44015 }
44016
44017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44018         LDKRouteHop this_ptr_conv;
44019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44020         this_ptr_conv.is_owned = false;
44021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44022         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
44023         int64_t ret_ref = 0;
44024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44027         ret_ref = (uintptr_t)ret_var.inner;
44028         if (ret_var.is_owned) {
44029                 ret_ref |= 1;
44030         }
44031         return ret_ref;
44032 }
44033
44034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44035         LDKRouteHop this_ptr_conv;
44036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44037         this_ptr_conv.is_owned = false;
44038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44039         LDKChannelFeatures val_conv;
44040         val_conv.inner = (void*)(val & (~1));
44041         val_conv.is_owned = (val & 1) || (val == 0);
44042         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44043         val_conv = ChannelFeatures_clone(&val_conv);
44044         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
44045 }
44046
44047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44048         LDKRouteHop this_ptr_conv;
44049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44050         this_ptr_conv.is_owned = false;
44051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44052         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
44053         return ret_conv;
44054 }
44055
44056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44057         LDKRouteHop this_ptr_conv;
44058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44059         this_ptr_conv.is_owned = false;
44060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44061         RouteHop_set_fee_msat(&this_ptr_conv, val);
44062 }
44063
44064 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44065         LDKRouteHop this_ptr_conv;
44066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44067         this_ptr_conv.is_owned = false;
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44069         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
44070         return ret_conv;
44071 }
44072
44073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44074         LDKRouteHop this_ptr_conv;
44075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44076         this_ptr_conv.is_owned = false;
44077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44078         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
44079 }
44080
44081 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) {
44082         LDKPublicKey pubkey_arg_ref;
44083         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
44084         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
44085         LDKNodeFeatures node_features_arg_conv;
44086         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
44087         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
44088         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
44089         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
44090         LDKChannelFeatures channel_features_arg_conv;
44091         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
44092         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
44093         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
44094         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
44095         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);
44096         int64_t ret_ref = 0;
44097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44100         ret_ref = (uintptr_t)ret_var.inner;
44101         if (ret_var.is_owned) {
44102                 ret_ref |= 1;
44103         }
44104         return ret_ref;
44105 }
44106
44107 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
44108         LDKRouteHop ret_var = RouteHop_clone(arg);
44109 int64_t ret_ref = 0;
44110 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44111 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44112 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44113 ret_ref = (uintptr_t)ret_var.inner;
44114 if (ret_var.is_owned) {
44115         ret_ref |= 1;
44116 }
44117         return ret_ref;
44118 }
44119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44120         LDKRouteHop arg_conv;
44121         arg_conv.inner = (void*)(arg & (~1));
44122         arg_conv.is_owned = false;
44123         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44124         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
44125         return ret_conv;
44126 }
44127
44128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44129         LDKRouteHop orig_conv;
44130         orig_conv.inner = (void*)(orig & (~1));
44131         orig_conv.is_owned = false;
44132         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44133         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
44134         int64_t ret_ref = 0;
44135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44138         ret_ref = (uintptr_t)ret_var.inner;
44139         if (ret_var.is_owned) {
44140                 ret_ref |= 1;
44141         }
44142         return ret_ref;
44143 }
44144
44145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
44146         LDKRouteHop o_conv;
44147         o_conv.inner = (void*)(o & (~1));
44148         o_conv.is_owned = false;
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44150         int64_t ret_conv = RouteHop_hash(&o_conv);
44151         return ret_conv;
44152 }
44153
44154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44155         LDKRouteHop a_conv;
44156         a_conv.inner = (void*)(a & (~1));
44157         a_conv.is_owned = false;
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44159         LDKRouteHop b_conv;
44160         b_conv.inner = (void*)(b & (~1));
44161         b_conv.is_owned = false;
44162         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44163         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
44164         return ret_conv;
44165 }
44166
44167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
44168         LDKRouteHop obj_conv;
44169         obj_conv.inner = (void*)(obj & (~1));
44170         obj_conv.is_owned = false;
44171         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44172         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
44173         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44174         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44175         CVec_u8Z_free(ret_var);
44176         return ret_arr;
44177 }
44178
44179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44180         LDKu8slice ser_ref;
44181         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44182         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44183         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
44184         *ret_conv = RouteHop_read(ser_ref);
44185         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44186         return (int64_t)ret_conv;
44187 }
44188
44189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44190         LDKRoute this_obj_conv;
44191         this_obj_conv.inner = (void*)(this_obj & (~1));
44192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44194         Route_free(this_obj_conv);
44195 }
44196
44197 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
44198         LDKRoute this_ptr_conv;
44199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44200         this_ptr_conv.is_owned = false;
44201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44202         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
44203         jobjectArray ret_arr = NULL;
44204         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
44205         ;
44206         for (size_t m = 0; m < ret_var.datalen; m++) {
44207                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
44208                 int64_tArray ret_conv_12_arr = NULL;
44209                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
44210                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
44211                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
44212                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
44213                         int64_t ret_conv_12_conv_10_ref = 0;
44214                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44215                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44216                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
44217                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
44218                         if (ret_conv_12_conv_10_var.is_owned) {
44219                                 ret_conv_12_conv_10_ref |= 1;
44220                         }
44221                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
44222                 }
44223                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
44224                 FREE(ret_conv_12_var.data);
44225                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
44226         }
44227         
44228         FREE(ret_var.data);
44229         return ret_arr;
44230 }
44231
44232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
44233         LDKRoute this_ptr_conv;
44234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44235         this_ptr_conv.is_owned = false;
44236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44237         LDKCVec_CVec_RouteHopZZ val_constr;
44238         val_constr.datalen = (*env)->GetArrayLength(env, val);
44239         if (val_constr.datalen > 0)
44240                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
44241         else
44242                 val_constr.data = NULL;
44243         for (size_t m = 0; m < val_constr.datalen; m++) {
44244                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
44245                 LDKCVec_RouteHopZ val_conv_12_constr;
44246                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
44247                 if (val_conv_12_constr.datalen > 0)
44248                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
44249                 else
44250                         val_conv_12_constr.data = NULL;
44251                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
44252                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
44253                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
44254                         LDKRouteHop val_conv_12_conv_10_conv;
44255                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
44256                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
44257                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
44258                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
44259                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
44260                 }
44261                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
44262                 val_constr.data[m] = val_conv_12_constr;
44263         }
44264         Route_set_paths(&this_ptr_conv, val_constr);
44265 }
44266
44267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
44268         LDKRoute this_ptr_conv;
44269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44270         this_ptr_conv.is_owned = false;
44271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44272         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
44273         int64_t ret_ref = 0;
44274         if ((uintptr_t)ret_var.inner > 4096) {
44275                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44276                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44278                 ret_ref = (uintptr_t)ret_var.inner;
44279                 if (ret_var.is_owned) {
44280                         ret_ref |= 1;
44281                 }
44282         }
44283         return ret_ref;
44284 }
44285
44286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44287         LDKRoute this_ptr_conv;
44288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44289         this_ptr_conv.is_owned = false;
44290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44291         LDKPaymentParameters val_conv;
44292         val_conv.inner = (void*)(val & (~1));
44293         val_conv.is_owned = (val & 1) || (val == 0);
44294         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44295         val_conv = PaymentParameters_clone(&val_conv);
44296         Route_set_payment_params(&this_ptr_conv, val_conv);
44297 }
44298
44299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
44300         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
44301         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
44302         if (paths_arg_constr.datalen > 0)
44303                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
44304         else
44305                 paths_arg_constr.data = NULL;
44306         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
44307                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
44308                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
44309                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
44310                 if (paths_arg_conv_12_constr.datalen > 0)
44311                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
44312                 else
44313                         paths_arg_conv_12_constr.data = NULL;
44314                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
44315                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
44316                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
44317                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
44318                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
44319                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
44320                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
44321                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
44322                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
44323                 }
44324                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
44325                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
44326         }
44327         LDKPaymentParameters payment_params_arg_conv;
44328         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
44329         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
44330         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
44331         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
44332         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
44333         int64_t ret_ref = 0;
44334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44337         ret_ref = (uintptr_t)ret_var.inner;
44338         if (ret_var.is_owned) {
44339                 ret_ref |= 1;
44340         }
44341         return ret_ref;
44342 }
44343
44344 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
44345         LDKRoute ret_var = Route_clone(arg);
44346 int64_t ret_ref = 0;
44347 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44348 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44349 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44350 ret_ref = (uintptr_t)ret_var.inner;
44351 if (ret_var.is_owned) {
44352         ret_ref |= 1;
44353 }
44354         return ret_ref;
44355 }
44356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44357         LDKRoute arg_conv;
44358         arg_conv.inner = (void*)(arg & (~1));
44359         arg_conv.is_owned = false;
44360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44361         int64_t ret_conv = Route_clone_ptr(&arg_conv);
44362         return ret_conv;
44363 }
44364
44365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44366         LDKRoute orig_conv;
44367         orig_conv.inner = (void*)(orig & (~1));
44368         orig_conv.is_owned = false;
44369         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44370         LDKRoute ret_var = Route_clone(&orig_conv);
44371         int64_t ret_ref = 0;
44372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44375         ret_ref = (uintptr_t)ret_var.inner;
44376         if (ret_var.is_owned) {
44377                 ret_ref |= 1;
44378         }
44379         return ret_ref;
44380 }
44381
44382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
44383         LDKRoute o_conv;
44384         o_conv.inner = (void*)(o & (~1));
44385         o_conv.is_owned = false;
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44387         int64_t ret_conv = Route_hash(&o_conv);
44388         return ret_conv;
44389 }
44390
44391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44392         LDKRoute a_conv;
44393         a_conv.inner = (void*)(a & (~1));
44394         a_conv.is_owned = false;
44395         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44396         LDKRoute b_conv;
44397         b_conv.inner = (void*)(b & (~1));
44398         b_conv.is_owned = false;
44399         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44400         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
44401         return ret_conv;
44402 }
44403
44404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
44405         LDKRoute this_arg_conv;
44406         this_arg_conv.inner = (void*)(this_arg & (~1));
44407         this_arg_conv.is_owned = false;
44408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44409         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
44410         return ret_conv;
44411 }
44412
44413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
44414         LDKRoute this_arg_conv;
44415         this_arg_conv.inner = (void*)(this_arg & (~1));
44416         this_arg_conv.is_owned = false;
44417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44418         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
44419         return ret_conv;
44420 }
44421
44422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
44423         LDKRoute obj_conv;
44424         obj_conv.inner = (void*)(obj & (~1));
44425         obj_conv.is_owned = false;
44426         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44427         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
44428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44430         CVec_u8Z_free(ret_var);
44431         return ret_arr;
44432 }
44433
44434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44435         LDKu8slice ser_ref;
44436         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44437         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44438         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
44439         *ret_conv = Route_read(ser_ref);
44440         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44441         return (int64_t)ret_conv;
44442 }
44443
44444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44445         LDKRouteParameters this_obj_conv;
44446         this_obj_conv.inner = (void*)(this_obj & (~1));
44447         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44449         RouteParameters_free(this_obj_conv);
44450 }
44451
44452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
44453         LDKRouteParameters this_ptr_conv;
44454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44455         this_ptr_conv.is_owned = false;
44456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44457         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
44458         int64_t ret_ref = 0;
44459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44462         ret_ref = (uintptr_t)ret_var.inner;
44463         if (ret_var.is_owned) {
44464                 ret_ref |= 1;
44465         }
44466         return ret_ref;
44467 }
44468
44469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44470         LDKRouteParameters this_ptr_conv;
44471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44472         this_ptr_conv.is_owned = false;
44473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44474         LDKPaymentParameters val_conv;
44475         val_conv.inner = (void*)(val & (~1));
44476         val_conv.is_owned = (val & 1) || (val == 0);
44477         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44478         val_conv = PaymentParameters_clone(&val_conv);
44479         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
44480 }
44481
44482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44483         LDKRouteParameters this_ptr_conv;
44484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44485         this_ptr_conv.is_owned = false;
44486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44487         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
44488         return ret_conv;
44489 }
44490
44491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44492         LDKRouteParameters this_ptr_conv;
44493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44494         this_ptr_conv.is_owned = false;
44495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44496         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
44497 }
44498
44499 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44500         LDKRouteParameters this_ptr_conv;
44501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44502         this_ptr_conv.is_owned = false;
44503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44504         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
44505         return ret_conv;
44506 }
44507
44508 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) {
44509         LDKRouteParameters this_ptr_conv;
44510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44511         this_ptr_conv.is_owned = false;
44512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44513         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
44514 }
44515
44516 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) {
44517         LDKPaymentParameters payment_params_arg_conv;
44518         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
44519         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
44520         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
44521         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
44522         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
44523         int64_t ret_ref = 0;
44524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44527         ret_ref = (uintptr_t)ret_var.inner;
44528         if (ret_var.is_owned) {
44529                 ret_ref |= 1;
44530         }
44531         return ret_ref;
44532 }
44533
44534 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
44535         LDKRouteParameters ret_var = RouteParameters_clone(arg);
44536 int64_t ret_ref = 0;
44537 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44538 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44539 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44540 ret_ref = (uintptr_t)ret_var.inner;
44541 if (ret_var.is_owned) {
44542         ret_ref |= 1;
44543 }
44544         return ret_ref;
44545 }
44546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44547         LDKRouteParameters arg_conv;
44548         arg_conv.inner = (void*)(arg & (~1));
44549         arg_conv.is_owned = false;
44550         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44551         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
44552         return ret_conv;
44553 }
44554
44555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44556         LDKRouteParameters orig_conv;
44557         orig_conv.inner = (void*)(orig & (~1));
44558         orig_conv.is_owned = false;
44559         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44560         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
44561         int64_t ret_ref = 0;
44562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44565         ret_ref = (uintptr_t)ret_var.inner;
44566         if (ret_var.is_owned) {
44567                 ret_ref |= 1;
44568         }
44569         return ret_ref;
44570 }
44571
44572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44573         LDKRouteParameters obj_conv;
44574         obj_conv.inner = (void*)(obj & (~1));
44575         obj_conv.is_owned = false;
44576         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44577         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
44578         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44579         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44580         CVec_u8Z_free(ret_var);
44581         return ret_arr;
44582 }
44583
44584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44585         LDKu8slice ser_ref;
44586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44588         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
44589         *ret_conv = RouteParameters_read(ser_ref);
44590         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44591         return (int64_t)ret_conv;
44592 }
44593
44594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44595         LDKPaymentParameters this_obj_conv;
44596         this_obj_conv.inner = (void*)(this_obj & (~1));
44597         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44599         PaymentParameters_free(this_obj_conv);
44600 }
44601
44602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44603         LDKPaymentParameters this_ptr_conv;
44604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44605         this_ptr_conv.is_owned = false;
44606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44607         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
44609         return ret_arr;
44610 }
44611
44612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44613         LDKPaymentParameters this_ptr_conv;
44614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44615         this_ptr_conv.is_owned = false;
44616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44617         LDKPublicKey val_ref;
44618         CHECK((*env)->GetArrayLength(env, val) == 33);
44619         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44620         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
44621 }
44622
44623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44624         LDKPaymentParameters this_ptr_conv;
44625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44626         this_ptr_conv.is_owned = false;
44627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44628         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
44629         int64_t ret_ref = 0;
44630         if ((uintptr_t)ret_var.inner > 4096) {
44631                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44632                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44634                 ret_ref = (uintptr_t)ret_var.inner;
44635                 if (ret_var.is_owned) {
44636                         ret_ref |= 1;
44637                 }
44638         }
44639         return ret_ref;
44640 }
44641
44642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44643         LDKPaymentParameters this_ptr_conv;
44644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44645         this_ptr_conv.is_owned = false;
44646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44647         LDKInvoiceFeatures val_conv;
44648         val_conv.inner = (void*)(val & (~1));
44649         val_conv.is_owned = (val & 1) || (val == 0);
44650         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44651         val_conv = InvoiceFeatures_clone(&val_conv);
44652         PaymentParameters_set_features(&this_ptr_conv, val_conv);
44653 }
44654
44655 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
44656         LDKPaymentParameters this_ptr_conv;
44657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44658         this_ptr_conv.is_owned = false;
44659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44660         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
44661         int64_tArray ret_arr = NULL;
44662         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44663         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44664         for (size_t l = 0; l < ret_var.datalen; l++) {
44665                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44666                 int64_t ret_conv_11_ref = 0;
44667                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44668                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44670                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44671                 if (ret_conv_11_var.is_owned) {
44672                         ret_conv_11_ref |= 1;
44673                 }
44674                 ret_arr_ptr[l] = ret_conv_11_ref;
44675         }
44676         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44677         FREE(ret_var.data);
44678         return ret_arr;
44679 }
44680
44681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44682         LDKPaymentParameters this_ptr_conv;
44683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44684         this_ptr_conv.is_owned = false;
44685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44686         LDKCVec_RouteHintZ val_constr;
44687         val_constr.datalen = (*env)->GetArrayLength(env, val);
44688         if (val_constr.datalen > 0)
44689                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
44690         else
44691                 val_constr.data = NULL;
44692         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44693         for (size_t l = 0; l < val_constr.datalen; l++) {
44694                 int64_t val_conv_11 = val_vals[l];
44695                 LDKRouteHint val_conv_11_conv;
44696                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
44697                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
44698                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
44699                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
44700                 val_constr.data[l] = val_conv_11_conv;
44701         }
44702         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44703         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
44704 }
44705
44706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
44707         LDKPaymentParameters this_ptr_conv;
44708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44709         this_ptr_conv.is_owned = false;
44710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44711         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44712         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
44713         int64_t ret_ref = (uintptr_t)ret_copy;
44714         return ret_ref;
44715 }
44716
44717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44718         LDKPaymentParameters this_ptr_conv;
44719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44720         this_ptr_conv.is_owned = false;
44721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44722         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
44723         CHECK_ACCESS(val_ptr);
44724         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44725         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
44726         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
44727 }
44728
44729 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44730         LDKPaymentParameters this_ptr_conv;
44731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44732         this_ptr_conv.is_owned = false;
44733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44734         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
44735         return ret_conv;
44736 }
44737
44738 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) {
44739         LDKPaymentParameters this_ptr_conv;
44740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44741         this_ptr_conv.is_owned = false;
44742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44743         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
44744 }
44745
44746 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1mpp_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
44747         LDKPaymentParameters this_ptr_conv;
44748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44749         this_ptr_conv.is_owned = false;
44750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44751         int8_t ret_conv = PaymentParameters_get_max_mpp_path_count(&this_ptr_conv);
44752         return ret_conv;
44753 }
44754
44755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1mpp_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
44756         LDKPaymentParameters this_ptr_conv;
44757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44758         this_ptr_conv.is_owned = false;
44759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44760         PaymentParameters_set_max_mpp_path_count(&this_ptr_conv, val);
44761 }
44762
44763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_mpp_path_count_arg) {
44764         LDKPublicKey payee_pubkey_arg_ref;
44765         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
44766         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
44767         LDKInvoiceFeatures features_arg_conv;
44768         features_arg_conv.inner = (void*)(features_arg & (~1));
44769         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44770         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44771         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
44772         LDKCVec_RouteHintZ route_hints_arg_constr;
44773         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
44774         if (route_hints_arg_constr.datalen > 0)
44775                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
44776         else
44777                 route_hints_arg_constr.data = NULL;
44778         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
44779         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
44780                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
44781                 LDKRouteHint route_hints_arg_conv_11_conv;
44782                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
44783                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
44784                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
44785                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
44786                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
44787         }
44788         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
44789         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
44790         CHECK_ACCESS(expiry_time_arg_ptr);
44791         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
44792         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
44793         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_mpp_path_count_arg);
44794         int64_t ret_ref = 0;
44795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44798         ret_ref = (uintptr_t)ret_var.inner;
44799         if (ret_var.is_owned) {
44800                 ret_ref |= 1;
44801         }
44802         return ret_ref;
44803 }
44804
44805 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
44806         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
44807 int64_t ret_ref = 0;
44808 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44809 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44810 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44811 ret_ref = (uintptr_t)ret_var.inner;
44812 if (ret_var.is_owned) {
44813         ret_ref |= 1;
44814 }
44815         return ret_ref;
44816 }
44817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44818         LDKPaymentParameters arg_conv;
44819         arg_conv.inner = (void*)(arg & (~1));
44820         arg_conv.is_owned = false;
44821         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44822         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
44823         return ret_conv;
44824 }
44825
44826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44827         LDKPaymentParameters orig_conv;
44828         orig_conv.inner = (void*)(orig & (~1));
44829         orig_conv.is_owned = false;
44830         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44831         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
44832         int64_t ret_ref = 0;
44833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44836         ret_ref = (uintptr_t)ret_var.inner;
44837         if (ret_var.is_owned) {
44838                 ret_ref |= 1;
44839         }
44840         return ret_ref;
44841 }
44842
44843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
44844         LDKPaymentParameters o_conv;
44845         o_conv.inner = (void*)(o & (~1));
44846         o_conv.is_owned = false;
44847         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44848         int64_t ret_conv = PaymentParameters_hash(&o_conv);
44849         return ret_conv;
44850 }
44851
44852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44853         LDKPaymentParameters a_conv;
44854         a_conv.inner = (void*)(a & (~1));
44855         a_conv.is_owned = false;
44856         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44857         LDKPaymentParameters b_conv;
44858         b_conv.inner = (void*)(b & (~1));
44859         b_conv.is_owned = false;
44860         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44861         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
44862         return ret_conv;
44863 }
44864
44865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44866         LDKPaymentParameters obj_conv;
44867         obj_conv.inner = (void*)(obj & (~1));
44868         obj_conv.is_owned = false;
44869         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44870         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
44871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44873         CVec_u8Z_free(ret_var);
44874         return ret_arr;
44875 }
44876
44877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44878         LDKu8slice ser_ref;
44879         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44880         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44881         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
44882         *ret_conv = PaymentParameters_read(ser_ref);
44883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44884         return (int64_t)ret_conv;
44885 }
44886
44887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44888         LDKPublicKey payee_pubkey_ref;
44889         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44890         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44891         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
44892         int64_t ret_ref = 0;
44893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44896         ret_ref = (uintptr_t)ret_var.inner;
44897         if (ret_var.is_owned) {
44898                 ret_ref |= 1;
44899         }
44900         return ret_ref;
44901 }
44902
44903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44904         LDKPublicKey payee_pubkey_ref;
44905         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44906         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44907         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
44908         int64_t ret_ref = 0;
44909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44912         ret_ref = (uintptr_t)ret_var.inner;
44913         if (ret_var.is_owned) {
44914                 ret_ref |= 1;
44915         }
44916         return ret_ref;
44917 }
44918
44919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44920         LDKRouteHint this_obj_conv;
44921         this_obj_conv.inner = (void*)(this_obj & (~1));
44922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44924         RouteHint_free(this_obj_conv);
44925 }
44926
44927 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44928         LDKRouteHint this_ptr_conv;
44929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44930         this_ptr_conv.is_owned = false;
44931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44932         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
44933         int64_tArray ret_arr = NULL;
44934         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44935         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44936         for (size_t o = 0; o < ret_var.datalen; o++) {
44937                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
44938                 int64_t ret_conv_14_ref = 0;
44939                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44940                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44941                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44942                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44943                 if (ret_conv_14_var.is_owned) {
44944                         ret_conv_14_ref |= 1;
44945                 }
44946                 ret_arr_ptr[o] = ret_conv_14_ref;
44947         }
44948         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44949         FREE(ret_var.data);
44950         return ret_arr;
44951 }
44952
44953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44954         LDKRouteHint this_ptr_conv;
44955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44956         this_ptr_conv.is_owned = false;
44957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44958         LDKCVec_RouteHintHopZ val_constr;
44959         val_constr.datalen = (*env)->GetArrayLength(env, val);
44960         if (val_constr.datalen > 0)
44961                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44962         else
44963                 val_constr.data = NULL;
44964         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44965         for (size_t o = 0; o < val_constr.datalen; o++) {
44966                 int64_t val_conv_14 = val_vals[o];
44967                 LDKRouteHintHop val_conv_14_conv;
44968                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
44969                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
44970                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
44971                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
44972                 val_constr.data[o] = val_conv_14_conv;
44973         }
44974         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44975         RouteHint_set_a(&this_ptr_conv, val_constr);
44976 }
44977
44978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
44979         LDKCVec_RouteHintHopZ a_arg_constr;
44980         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
44981         if (a_arg_constr.datalen > 0)
44982                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44983         else
44984                 a_arg_constr.data = NULL;
44985         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
44986         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
44987                 int64_t a_arg_conv_14 = a_arg_vals[o];
44988                 LDKRouteHintHop a_arg_conv_14_conv;
44989                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
44990                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
44991                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
44992                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
44993                 a_arg_constr.data[o] = a_arg_conv_14_conv;
44994         }
44995         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
44996         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
44997         int64_t ret_ref = 0;
44998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45001         ret_ref = (uintptr_t)ret_var.inner;
45002         if (ret_var.is_owned) {
45003                 ret_ref |= 1;
45004         }
45005         return ret_ref;
45006 }
45007
45008 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
45009         LDKRouteHint ret_var = RouteHint_clone(arg);
45010 int64_t ret_ref = 0;
45011 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45012 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45013 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45014 ret_ref = (uintptr_t)ret_var.inner;
45015 if (ret_var.is_owned) {
45016         ret_ref |= 1;
45017 }
45018         return ret_ref;
45019 }
45020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45021         LDKRouteHint arg_conv;
45022         arg_conv.inner = (void*)(arg & (~1));
45023         arg_conv.is_owned = false;
45024         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45025         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
45026         return ret_conv;
45027 }
45028
45029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45030         LDKRouteHint orig_conv;
45031         orig_conv.inner = (void*)(orig & (~1));
45032         orig_conv.is_owned = false;
45033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45034         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
45035         int64_t ret_ref = 0;
45036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45039         ret_ref = (uintptr_t)ret_var.inner;
45040         if (ret_var.is_owned) {
45041                 ret_ref |= 1;
45042         }
45043         return ret_ref;
45044 }
45045
45046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
45047         LDKRouteHint o_conv;
45048         o_conv.inner = (void*)(o & (~1));
45049         o_conv.is_owned = false;
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45051         int64_t ret_conv = RouteHint_hash(&o_conv);
45052         return ret_conv;
45053 }
45054
45055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45056         LDKRouteHint a_conv;
45057         a_conv.inner = (void*)(a & (~1));
45058         a_conv.is_owned = false;
45059         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45060         LDKRouteHint b_conv;
45061         b_conv.inner = (void*)(b & (~1));
45062         b_conv.is_owned = false;
45063         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45064         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
45065         return ret_conv;
45066 }
45067
45068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
45069         LDKRouteHint obj_conv;
45070         obj_conv.inner = (void*)(obj & (~1));
45071         obj_conv.is_owned = false;
45072         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45073         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
45074         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45075         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45076         CVec_u8Z_free(ret_var);
45077         return ret_arr;
45078 }
45079
45080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45081         LDKu8slice ser_ref;
45082         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45083         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45084         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
45085         *ret_conv = RouteHint_read(ser_ref);
45086         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45087         return (int64_t)ret_conv;
45088 }
45089
45090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45091         LDKRouteHintHop this_obj_conv;
45092         this_obj_conv.inner = (void*)(this_obj & (~1));
45093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45095         RouteHintHop_free(this_obj_conv);
45096 }
45097
45098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45099         LDKRouteHintHop this_ptr_conv;
45100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45101         this_ptr_conv.is_owned = false;
45102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45103         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
45105         return ret_arr;
45106 }
45107
45108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45109         LDKRouteHintHop this_ptr_conv;
45110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45111         this_ptr_conv.is_owned = false;
45112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45113         LDKPublicKey val_ref;
45114         CHECK((*env)->GetArrayLength(env, val) == 33);
45115         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45116         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
45117 }
45118
45119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45120         LDKRouteHintHop this_ptr_conv;
45121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45122         this_ptr_conv.is_owned = false;
45123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45124         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
45125         return ret_conv;
45126 }
45127
45128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45129         LDKRouteHintHop this_ptr_conv;
45130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45131         this_ptr_conv.is_owned = false;
45132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45133         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
45134 }
45135
45136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
45137         LDKRouteHintHop this_ptr_conv;
45138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45139         this_ptr_conv.is_owned = false;
45140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45141         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
45142         int64_t ret_ref = 0;
45143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45146         ret_ref = (uintptr_t)ret_var.inner;
45147         if (ret_var.is_owned) {
45148                 ret_ref |= 1;
45149         }
45150         return ret_ref;
45151 }
45152
45153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45154         LDKRouteHintHop this_ptr_conv;
45155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45156         this_ptr_conv.is_owned = false;
45157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45158         LDKRoutingFees val_conv;
45159         val_conv.inner = (void*)(val & (~1));
45160         val_conv.is_owned = (val & 1) || (val == 0);
45161         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45162         val_conv = RoutingFees_clone(&val_conv);
45163         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
45164 }
45165
45166 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45167         LDKRouteHintHop this_ptr_conv;
45168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45169         this_ptr_conv.is_owned = false;
45170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45171         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
45172         return ret_conv;
45173 }
45174
45175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
45176         LDKRouteHintHop this_ptr_conv;
45177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45178         this_ptr_conv.is_owned = false;
45179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45180         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
45181 }
45182
45183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45184         LDKRouteHintHop this_ptr_conv;
45185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45186         this_ptr_conv.is_owned = false;
45187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45188         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45189         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
45190         int64_t ret_ref = (uintptr_t)ret_copy;
45191         return ret_ref;
45192 }
45193
45194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45195         LDKRouteHintHop this_ptr_conv;
45196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45197         this_ptr_conv.is_owned = false;
45198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45199         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45200         CHECK_ACCESS(val_ptr);
45201         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45202         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45203         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
45204 }
45205
45206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45207         LDKRouteHintHop this_ptr_conv;
45208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45209         this_ptr_conv.is_owned = false;
45210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45211         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45212         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
45213         int64_t ret_ref = (uintptr_t)ret_copy;
45214         return ret_ref;
45215 }
45216
45217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45218         LDKRouteHintHop this_ptr_conv;
45219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45220         this_ptr_conv.is_owned = false;
45221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45222         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45223         CHECK_ACCESS(val_ptr);
45224         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45225         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45226         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
45227 }
45228
45229 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) {
45230         LDKPublicKey src_node_id_arg_ref;
45231         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
45232         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
45233         LDKRoutingFees fees_arg_conv;
45234         fees_arg_conv.inner = (void*)(fees_arg & (~1));
45235         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
45236         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
45237         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
45238         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
45239         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
45240         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
45241         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
45242         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
45243         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
45244         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
45245         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
45246         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);
45247         int64_t ret_ref = 0;
45248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45251         ret_ref = (uintptr_t)ret_var.inner;
45252         if (ret_var.is_owned) {
45253                 ret_ref |= 1;
45254         }
45255         return ret_ref;
45256 }
45257
45258 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
45259         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
45260 int64_t ret_ref = 0;
45261 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45262 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45263 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45264 ret_ref = (uintptr_t)ret_var.inner;
45265 if (ret_var.is_owned) {
45266         ret_ref |= 1;
45267 }
45268         return ret_ref;
45269 }
45270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45271         LDKRouteHintHop arg_conv;
45272         arg_conv.inner = (void*)(arg & (~1));
45273         arg_conv.is_owned = false;
45274         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45275         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
45276         return ret_conv;
45277 }
45278
45279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45280         LDKRouteHintHop orig_conv;
45281         orig_conv.inner = (void*)(orig & (~1));
45282         orig_conv.is_owned = false;
45283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45284         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
45285         int64_t ret_ref = 0;
45286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45289         ret_ref = (uintptr_t)ret_var.inner;
45290         if (ret_var.is_owned) {
45291                 ret_ref |= 1;
45292         }
45293         return ret_ref;
45294 }
45295
45296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
45297         LDKRouteHintHop o_conv;
45298         o_conv.inner = (void*)(o & (~1));
45299         o_conv.is_owned = false;
45300         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45301         int64_t ret_conv = RouteHintHop_hash(&o_conv);
45302         return ret_conv;
45303 }
45304
45305 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45306         LDKRouteHintHop a_conv;
45307         a_conv.inner = (void*)(a & (~1));
45308         a_conv.is_owned = false;
45309         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45310         LDKRouteHintHop b_conv;
45311         b_conv.inner = (void*)(b & (~1));
45312         b_conv.is_owned = false;
45313         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45314         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
45315         return ret_conv;
45316 }
45317
45318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
45319         LDKRouteHintHop obj_conv;
45320         obj_conv.inner = (void*)(obj & (~1));
45321         obj_conv.is_owned = false;
45322         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45323         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
45324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45326         CVec_u8Z_free(ret_var);
45327         return ret_arr;
45328 }
45329
45330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45331         LDKu8slice ser_ref;
45332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45334         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
45335         *ret_conv = RouteHintHop_read(ser_ref);
45336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45337         return (int64_t)ret_conv;
45338 }
45339
45340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
45341         LDKPublicKey our_node_pubkey_ref;
45342         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
45343         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
45344         LDKRouteParameters route_params_conv;
45345         route_params_conv.inner = (void*)(route_params & (~1));
45346         route_params_conv.is_owned = false;
45347         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
45348         LDKNetworkGraph network_graph_conv;
45349         network_graph_conv.inner = (void*)(network_graph & (~1));
45350         network_graph_conv.is_owned = false;
45351         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45352         LDKCVec_ChannelDetailsZ first_hops_constr;
45353         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
45354         if (first_hops != NULL) {
45355                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
45356                 if (first_hops_constr.datalen > 0)
45357                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
45358                 else
45359                         first_hops_constr.data = NULL;
45360                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
45361                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
45362                         int64_t first_hops_conv_16 = first_hops_vals[q];
45363                         LDKChannelDetails first_hops_conv_16_conv;
45364                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
45365                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
45366                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
45367                         first_hops_constr.data[q] = first_hops_conv_16_conv;
45368                 }
45369                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
45370                 first_hops_ptr = &first_hops_constr;
45371         }
45372         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45373         CHECK_ACCESS(logger_ptr);
45374         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45375         if (logger_conv.free == LDKLogger_JCalls_free) {
45376                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45377                 LDKLogger_JCalls_cloned(&logger_conv);
45378         }
45379         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
45380         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
45381         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
45382         unsigned char random_seed_bytes_arr[32];
45383         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
45384         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
45385         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
45386         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
45387         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
45388         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
45389         return (int64_t)ret_conv;
45390 }
45391
45392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_build_1route_1from_1hops(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, jobjectArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
45393         LDKPublicKey our_node_pubkey_ref;
45394         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
45395         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
45396         LDKCVec_PublicKeyZ hops_constr;
45397         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
45398         if (hops_constr.datalen > 0)
45399                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
45400         else
45401                 hops_constr.data = NULL;
45402         for (size_t i = 0; i < hops_constr.datalen; i++) {
45403                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
45404                 LDKPublicKey hops_conv_8_ref;
45405                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
45406                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
45407                 hops_constr.data[i] = hops_conv_8_ref;
45408         }
45409         LDKRouteParameters route_params_conv;
45410         route_params_conv.inner = (void*)(route_params & (~1));
45411         route_params_conv.is_owned = false;
45412         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
45413         LDKNetworkGraph network_graph_conv;
45414         network_graph_conv.inner = (void*)(network_graph & (~1));
45415         network_graph_conv.is_owned = false;
45416         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45417         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45418         CHECK_ACCESS(logger_ptr);
45419         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45420         if (logger_conv.free == LDKLogger_JCalls_free) {
45421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45422                 LDKLogger_JCalls_cloned(&logger_conv);
45423         }
45424         unsigned char random_seed_bytes_arr[32];
45425         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
45426         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
45427         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
45428         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
45429         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
45430         return (int64_t)ret_conv;
45431 }
45432
45433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45434         if ((this_ptr & 1) != 0) return;
45435         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45436         CHECK_ACCESS(this_ptr_ptr);
45437         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
45438         FREE((void*)this_ptr);
45439         Score_free(this_ptr_conv);
45440 }
45441
45442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45443         if ((this_ptr & 1) != 0) return;
45444         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45445         CHECK_ACCESS(this_ptr_ptr);
45446         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
45447         FREE((void*)this_ptr);
45448         LockableScore_free(this_ptr_conv);
45449 }
45450
45451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45452         LDKMultiThreadedLockableScore this_obj_conv;
45453         this_obj_conv.inner = (void*)(this_obj & (~1));
45454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45456         MultiThreadedLockableScore_free(this_obj_conv);
45457 }
45458
45459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
45460         LDKMultiThreadedLockableScore obj_conv;
45461         obj_conv.inner = (void*)(obj & (~1));
45462         obj_conv.is_owned = false;
45463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45464         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
45465         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45466         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45467         CVec_u8Z_free(ret_var);
45468         return ret_arr;
45469 }
45470
45471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
45472         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
45473         CHECK_ACCESS(score_ptr);
45474         LDKScore score_conv = *(LDKScore*)(score_ptr);
45475         if (score_conv.free == LDKScore_JCalls_free) {
45476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45477                 LDKScore_JCalls_cloned(&score_conv);
45478         }
45479         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
45480         int64_t ret_ref = 0;
45481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45484         ret_ref = (uintptr_t)ret_var.inner;
45485         if (ret_var.is_owned) {
45486                 ret_ref |= 1;
45487         }
45488         return ret_ref;
45489 }
45490
45491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45492         LDKChannelUsage this_obj_conv;
45493         this_obj_conv.inner = (void*)(this_obj & (~1));
45494         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45496         ChannelUsage_free(this_obj_conv);
45497 }
45498
45499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45500         LDKChannelUsage this_ptr_conv;
45501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45502         this_ptr_conv.is_owned = false;
45503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45504         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
45505         return ret_conv;
45506 }
45507
45508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45509         LDKChannelUsage this_ptr_conv;
45510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45511         this_ptr_conv.is_owned = false;
45512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45513         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
45514 }
45515
45516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45517         LDKChannelUsage this_ptr_conv;
45518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45519         this_ptr_conv.is_owned = false;
45520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45521         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
45522         return ret_conv;
45523 }
45524
45525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45526         LDKChannelUsage this_ptr_conv;
45527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45528         this_ptr_conv.is_owned = false;
45529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45530         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
45531 }
45532
45533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
45534         LDKChannelUsage this_ptr_conv;
45535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45536         this_ptr_conv.is_owned = false;
45537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45538         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45539         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
45540         int64_t ret_ref = (uintptr_t)ret_copy;
45541         return ret_ref;
45542 }
45543
45544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45545         LDKChannelUsage this_ptr_conv;
45546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45547         this_ptr_conv.is_owned = false;
45548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45549         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45550         CHECK_ACCESS(val_ptr);
45551         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
45552         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
45553         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
45554 }
45555
45556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1new(JNIEnv *env, jclass clz, int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
45557         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
45558         CHECK_ACCESS(effective_capacity_arg_ptr);
45559         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
45560         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
45561         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
45562         int64_t ret_ref = 0;
45563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45566         ret_ref = (uintptr_t)ret_var.inner;
45567         if (ret_var.is_owned) {
45568                 ret_ref |= 1;
45569         }
45570         return ret_ref;
45571 }
45572
45573 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
45574         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
45575 int64_t ret_ref = 0;
45576 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45577 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45578 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45579 ret_ref = (uintptr_t)ret_var.inner;
45580 if (ret_var.is_owned) {
45581         ret_ref |= 1;
45582 }
45583         return ret_ref;
45584 }
45585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45586         LDKChannelUsage arg_conv;
45587         arg_conv.inner = (void*)(arg & (~1));
45588         arg_conv.is_owned = false;
45589         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45590         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
45591         return ret_conv;
45592 }
45593
45594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45595         LDKChannelUsage orig_conv;
45596         orig_conv.inner = (void*)(orig & (~1));
45597         orig_conv.is_owned = false;
45598         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45599         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
45600         int64_t ret_ref = 0;
45601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45604         ret_ref = (uintptr_t)ret_var.inner;
45605         if (ret_var.is_owned) {
45606                 ret_ref |= 1;
45607         }
45608         return ret_ref;
45609 }
45610
45611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45612         LDKFixedPenaltyScorer this_obj_conv;
45613         this_obj_conv.inner = (void*)(this_obj & (~1));
45614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45616         FixedPenaltyScorer_free(this_obj_conv);
45617 }
45618
45619 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
45620         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
45621 int64_t ret_ref = 0;
45622 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45623 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45624 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45625 ret_ref = (uintptr_t)ret_var.inner;
45626 if (ret_var.is_owned) {
45627         ret_ref |= 1;
45628 }
45629         return ret_ref;
45630 }
45631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45632         LDKFixedPenaltyScorer arg_conv;
45633         arg_conv.inner = (void*)(arg & (~1));
45634         arg_conv.is_owned = false;
45635         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45636         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
45637         return ret_conv;
45638 }
45639
45640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45641         LDKFixedPenaltyScorer orig_conv;
45642         orig_conv.inner = (void*)(orig & (~1));
45643         orig_conv.is_owned = false;
45644         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45645         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
45646         int64_t ret_ref = 0;
45647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45650         ret_ref = (uintptr_t)ret_var.inner;
45651         if (ret_var.is_owned) {
45652                 ret_ref |= 1;
45653         }
45654         return ret_ref;
45655 }
45656
45657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
45658         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
45659         int64_t ret_ref = 0;
45660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45663         ret_ref = (uintptr_t)ret_var.inner;
45664         if (ret_var.is_owned) {
45665                 ret_ref |= 1;
45666         }
45667         return ret_ref;
45668 }
45669
45670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45671         LDKFixedPenaltyScorer this_arg_conv;
45672         this_arg_conv.inner = (void*)(this_arg & (~1));
45673         this_arg_conv.is_owned = false;
45674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45675         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45676         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
45677         return (int64_t)ret_ret;
45678 }
45679
45680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45681         LDKFixedPenaltyScorer obj_conv;
45682         obj_conv.inner = (void*)(obj & (~1));
45683         obj_conv.is_owned = false;
45684         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45685         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
45686         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45687         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45688         CVec_u8Z_free(ret_var);
45689         return ret_arr;
45690 }
45691
45692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
45693         LDKu8slice ser_ref;
45694         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45695         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45696         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
45697         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
45698         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45699         return (int64_t)ret_conv;
45700 }
45701
45702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45703         LDKProbabilisticScorer this_obj_conv;
45704         this_obj_conv.inner = (void*)(this_obj & (~1));
45705         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45707         ProbabilisticScorer_free(this_obj_conv);
45708 }
45709
45710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45711         LDKProbabilisticScoringParameters this_obj_conv;
45712         this_obj_conv.inner = (void*)(this_obj & (~1));
45713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45715         ProbabilisticScoringParameters_free(this_obj_conv);
45716 }
45717
45718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45719         LDKProbabilisticScoringParameters this_ptr_conv;
45720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45721         this_ptr_conv.is_owned = false;
45722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45723         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
45724         return ret_conv;
45725 }
45726
45727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45728         LDKProbabilisticScoringParameters this_ptr_conv;
45729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45730         this_ptr_conv.is_owned = false;
45731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45732         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
45733 }
45734
45735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45736         LDKProbabilisticScoringParameters this_ptr_conv;
45737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45738         this_ptr_conv.is_owned = false;
45739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45740         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
45741         return ret_conv;
45742 }
45743
45744 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) {
45745         LDKProbabilisticScoringParameters this_ptr_conv;
45746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45747         this_ptr_conv.is_owned = false;
45748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45749         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
45750 }
45751
45752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
45753         LDKProbabilisticScoringParameters this_ptr_conv;
45754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45755         this_ptr_conv.is_owned = false;
45756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45757         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
45758         return ret_conv;
45759 }
45760
45761 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) {
45762         LDKProbabilisticScoringParameters this_ptr_conv;
45763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45764         this_ptr_conv.is_owned = false;
45765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45766         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
45767 }
45768
45769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45770         LDKProbabilisticScoringParameters this_ptr_conv;
45771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45772         this_ptr_conv.is_owned = false;
45773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45774         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
45775         return ret_conv;
45776 }
45777
45778 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) {
45779         LDKProbabilisticScoringParameters this_ptr_conv;
45780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45781         this_ptr_conv.is_owned = false;
45782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45783         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
45784 }
45785
45786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45787         LDKProbabilisticScoringParameters this_ptr_conv;
45788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45789         this_ptr_conv.is_owned = false;
45790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45791         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
45792         return ret_conv;
45793 }
45794
45795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45796         LDKProbabilisticScoringParameters this_ptr_conv;
45797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45798         this_ptr_conv.is_owned = false;
45799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45800         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
45801 }
45802
45803 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
45804         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
45805 int64_t ret_ref = 0;
45806 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45807 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45808 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45809 ret_ref = (uintptr_t)ret_var.inner;
45810 if (ret_var.is_owned) {
45811         ret_ref |= 1;
45812 }
45813         return ret_ref;
45814 }
45815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45816         LDKProbabilisticScoringParameters arg_conv;
45817         arg_conv.inner = (void*)(arg & (~1));
45818         arg_conv.is_owned = false;
45819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45820         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
45821         return ret_conv;
45822 }
45823
45824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45825         LDKProbabilisticScoringParameters orig_conv;
45826         orig_conv.inner = (void*)(orig & (~1));
45827         orig_conv.is_owned = false;
45828         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45829         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
45830         int64_t ret_ref = 0;
45831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45834         ret_ref = (uintptr_t)ret_var.inner;
45835         if (ret_var.is_owned) {
45836                 ret_ref |= 1;
45837         }
45838         return ret_ref;
45839 }
45840
45841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
45842         LDKProbabilisticScoringParameters params_conv;
45843         params_conv.inner = (void*)(params & (~1));
45844         params_conv.is_owned = (params & 1) || (params == 0);
45845         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
45846         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
45847         LDKNetworkGraph network_graph_conv;
45848         network_graph_conv.inner = (void*)(network_graph & (~1));
45849         network_graph_conv.is_owned = false;
45850         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45851         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45852         CHECK_ACCESS(logger_ptr);
45853         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45854         if (logger_conv.free == LDKLogger_JCalls_free) {
45855                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45856                 LDKLogger_JCalls_cloned(&logger_conv);
45857         }
45858         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
45859         int64_t ret_ref = 0;
45860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45863         ret_ref = (uintptr_t)ret_var.inner;
45864         if (ret_var.is_owned) {
45865                 ret_ref |= 1;
45866         }
45867         return ret_ref;
45868 }
45869
45870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
45871         LDKProbabilisticScorer this_arg_conv;
45872         this_arg_conv.inner = (void*)(this_arg & (~1));
45873         this_arg_conv.is_owned = false;
45874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45875         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
45876 }
45877
45878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1estimated_1channel_1liquidity_1range(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
45879         LDKProbabilisticScorer this_arg_conv;
45880         this_arg_conv.inner = (void*)(this_arg & (~1));
45881         this_arg_conv.is_owned = false;
45882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45883         LDKNodeId target_conv;
45884         target_conv.inner = (void*)(target & (~1));
45885         target_conv.is_owned = false;
45886         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
45887         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
45888         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
45889         int64_t ret_ref = (uintptr_t)ret_copy;
45890         return ret_ref;
45891 }
45892
45893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45894         LDKProbabilisticScorer this_arg_conv;
45895         this_arg_conv.inner = (void*)(this_arg & (~1));
45896         this_arg_conv.is_owned = false;
45897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45898         LDKNodeId node_id_conv;
45899         node_id_conv.inner = (void*)(node_id & (~1));
45900         node_id_conv.is_owned = false;
45901         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45902         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
45903 }
45904
45905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45906         LDKProbabilisticScorer this_arg_conv;
45907         this_arg_conv.inner = (void*)(this_arg & (~1));
45908         this_arg_conv.is_owned = false;
45909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45910         LDKNodeId node_id_conv;
45911         node_id_conv.inner = (void*)(node_id & (~1));
45912         node_id_conv.is_owned = false;
45913         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45914         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
45915 }
45916
45917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1banned(JNIEnv *env, jclass clz, int64_t this_arg) {
45918         LDKProbabilisticScorer this_arg_conv;
45919         this_arg_conv.inner = (void*)(this_arg & (~1));
45920         this_arg_conv.is_owned = false;
45921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45922         ProbabilisticScorer_clear_banned(&this_arg_conv);
45923 }
45924
45925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1add_1banned_1from_1list(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray node_ids) {
45926         LDKProbabilisticScoringParameters this_arg_conv;
45927         this_arg_conv.inner = (void*)(this_arg & (~1));
45928         this_arg_conv.is_owned = false;
45929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45930         LDKCVec_NodeIdZ node_ids_constr;
45931         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
45932         if (node_ids_constr.datalen > 0)
45933                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
45934         else
45935                 node_ids_constr.data = NULL;
45936         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
45937         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
45938                 int64_t node_ids_conv_8 = node_ids_vals[i];
45939                 LDKNodeId node_ids_conv_8_conv;
45940                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
45941                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
45942                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
45943                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
45944                 node_ids_constr.data[i] = node_ids_conv_8_conv;
45945         }
45946         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
45947         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
45948 }
45949
45950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
45951         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
45952         int64_t ret_ref = 0;
45953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45956         ret_ref = (uintptr_t)ret_var.inner;
45957         if (ret_var.is_owned) {
45958                 ret_ref |= 1;
45959         }
45960         return ret_ref;
45961 }
45962
45963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45964         LDKProbabilisticScorer this_arg_conv;
45965         this_arg_conv.inner = (void*)(this_arg & (~1));
45966         this_arg_conv.is_owned = false;
45967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45968         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45969         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
45970         return (int64_t)ret_ret;
45971 }
45972
45973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45974         LDKProbabilisticScorer obj_conv;
45975         obj_conv.inner = (void*)(obj & (~1));
45976         obj_conv.is_owned = false;
45977         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45978         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
45979         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45980         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45981         CVec_u8Z_free(ret_var);
45982         return ret_arr;
45983 }
45984
45985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
45986         LDKu8slice ser_ref;
45987         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45988         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45989         LDKProbabilisticScoringParameters arg_a_conv;
45990         arg_a_conv.inner = (void*)(arg_a & (~1));
45991         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
45992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
45993         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
45994         LDKNetworkGraph arg_b_conv;
45995         arg_b_conv.inner = (void*)(arg_b & (~1));
45996         arg_b_conv.is_owned = false;
45997         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
45998         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
45999         CHECK_ACCESS(arg_c_ptr);
46000         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
46001         if (arg_c_conv.free == LDKLogger_JCalls_free) {
46002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46003                 LDKLogger_JCalls_cloned(&arg_c_conv);
46004         }
46005         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
46006         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
46007         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46008         return (int64_t)ret_conv;
46009 }
46010
46011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46012         LDKFilesystemPersister this_obj_conv;
46013         this_obj_conv.inner = (void*)(this_obj & (~1));
46014         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46016         FilesystemPersister_free(this_obj_conv);
46017 }
46018
46019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
46020         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
46021         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
46022         int64_t ret_ref = 0;
46023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46026         ret_ref = (uintptr_t)ret_var.inner;
46027         if (ret_var.is_owned) {
46028                 ret_ref |= 1;
46029         }
46030         return ret_ref;
46031 }
46032
46033 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
46034         LDKFilesystemPersister this_arg_conv;
46035         this_arg_conv.inner = (void*)(this_arg & (~1));
46036         this_arg_conv.is_owned = false;
46037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46038         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
46039         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46040         Str_free(ret_str);
46041         return ret_conv;
46042 }
46043
46044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
46045         LDKFilesystemPersister this_arg_conv;
46046         this_arg_conv.inner = (void*)(this_arg & (~1));
46047         this_arg_conv.is_owned = false;
46048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46049         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46050         CHECK_ACCESS(keys_manager_ptr);
46051         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46052         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46053                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46054                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46055         }
46056         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
46057         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
46058         return (int64_t)ret_conv;
46059 }
46060
46061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46062         LDKBackgroundProcessor this_obj_conv;
46063         this_obj_conv.inner = (void*)(this_obj & (~1));
46064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46066         BackgroundProcessor_free(this_obj_conv);
46067 }
46068
46069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46070         if ((this_ptr & 1) != 0) return;
46071         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46072         CHECK_ACCESS(this_ptr_ptr);
46073         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
46074         FREE((void*)this_ptr);
46075         GossipSync_free(this_ptr_conv);
46076 }
46077
46078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
46079         LDKP2PGossipSync a_conv;
46080         a_conv.inner = (void*)(a & (~1));
46081         a_conv.is_owned = false;
46082         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46083         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46084         *ret_copy = GossipSync_p2_p(&a_conv);
46085         int64_t ret_ref = (uintptr_t)ret_copy;
46086         return ret_ref;
46087 }
46088
46089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
46090         LDKRapidGossipSync a_conv;
46091         a_conv.inner = (void*)(a & (~1));
46092         a_conv.is_owned = false;
46093         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46094         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46095         *ret_copy = GossipSync_rapid(&a_conv);
46096         int64_t ret_ref = (uintptr_t)ret_copy;
46097         return ret_ref;
46098 }
46099
46100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
46101         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46102         *ret_copy = GossipSync_none();
46103         int64_t ret_ref = (uintptr_t)ret_copy;
46104         return ret_ref;
46105 }
46106
46107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
46108         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
46109         CHECK_ACCESS(persister_ptr);
46110         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
46111         if (persister_conv.free == LDKPersister_JCalls_free) {
46112                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46113                 LDKPersister_JCalls_cloned(&persister_conv);
46114         }
46115         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
46116         CHECK_ACCESS(event_handler_ptr);
46117         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
46118         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
46119                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46120                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
46121         }
46122         LDKChainMonitor chain_monitor_conv;
46123         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
46124         chain_monitor_conv.is_owned = false;
46125         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
46126         LDKChannelManager channel_manager_conv;
46127         channel_manager_conv.inner = (void*)(channel_manager & (~1));
46128         channel_manager_conv.is_owned = false;
46129         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
46130         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
46131         CHECK_ACCESS(gossip_sync_ptr);
46132         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
46133         // WARNING: we may need a move here but no clone is available for LDKGossipSync
46134         LDKPeerManager peer_manager_conv;
46135         peer_manager_conv.inner = (void*)(peer_manager & (~1));
46136         peer_manager_conv.is_owned = false;
46137         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
46138         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46139         CHECK_ACCESS(logger_ptr);
46140         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46141         if (logger_conv.free == LDKLogger_JCalls_free) {
46142                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46143                 LDKLogger_JCalls_cloned(&logger_conv);
46144         }
46145         LDKMultiThreadedLockableScore scorer_conv;
46146         scorer_conv.inner = (void*)(scorer & (~1));
46147         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
46148         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
46149         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
46150         int64_t ret_ref = 0;
46151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46154         ret_ref = (uintptr_t)ret_var.inner;
46155         if (ret_var.is_owned) {
46156                 ret_ref |= 1;
46157         }
46158         return ret_ref;
46159 }
46160
46161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
46162         LDKBackgroundProcessor this_arg_conv;
46163         this_arg_conv.inner = (void*)(this_arg & (~1));
46164         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
46165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46166         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
46167         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
46168         *ret_conv = BackgroundProcessor_join(this_arg_conv);
46169         return (int64_t)ret_conv;
46170 }
46171
46172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
46173         LDKBackgroundProcessor this_arg_conv;
46174         this_arg_conv.inner = (void*)(this_arg & (~1));
46175         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
46176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46177         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
46178         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
46179         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
46180         return (int64_t)ret_conv;
46181 }
46182
46183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46184         if ((this_ptr & 1) != 0) return;
46185         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46186         CHECK_ACCESS(this_ptr_ptr);
46187         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
46188         FREE((void*)this_ptr);
46189         ParseError_free(this_ptr_conv);
46190 }
46191
46192 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
46193         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46194         *ret_copy = ParseError_clone(arg);
46195 int64_t ret_ref = (uintptr_t)ret_copy;
46196         return ret_ref;
46197 }
46198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46199         LDKParseError* arg_conv = (LDKParseError*)arg;
46200         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
46201         return ret_conv;
46202 }
46203
46204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46205         LDKParseError* orig_conv = (LDKParseError*)orig;
46206         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46207         *ret_copy = ParseError_clone(orig_conv);
46208         int64_t ret_ref = (uintptr_t)ret_copy;
46209         return ret_ref;
46210 }
46211
46212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
46213         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
46214         CHECK_ACCESS(a_ptr);
46215         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
46216         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
46217         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46218         *ret_copy = ParseError_bech32_error(a_conv);
46219         int64_t ret_ref = (uintptr_t)ret_copy;
46220         return ret_ref;
46221 }
46222
46223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
46224         
46225         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46226         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
46227         int64_t ret_ref = (uintptr_t)ret_copy;
46228         return ret_ref;
46229 }
46230
46231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
46232         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
46233         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46234         *ret_copy = ParseError_malformed_signature(a_conv);
46235         int64_t ret_ref = (uintptr_t)ret_copy;
46236         return ret_ref;
46237 }
46238
46239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
46240         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46241         *ret_copy = ParseError_bad_prefix();
46242         int64_t ret_ref = (uintptr_t)ret_copy;
46243         return ret_ref;
46244 }
46245
46246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
46247         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46248         *ret_copy = ParseError_unknown_currency();
46249         int64_t ret_ref = (uintptr_t)ret_copy;
46250         return ret_ref;
46251 }
46252
46253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
46254         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46255         *ret_copy = ParseError_unknown_si_prefix();
46256         int64_t ret_ref = (uintptr_t)ret_copy;
46257         return ret_ref;
46258 }
46259
46260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
46261         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46262         *ret_copy = ParseError_malformed_hrp();
46263         int64_t ret_ref = (uintptr_t)ret_copy;
46264         return ret_ref;
46265 }
46266
46267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
46268         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46269         *ret_copy = ParseError_too_short_data_part();
46270         int64_t ret_ref = (uintptr_t)ret_copy;
46271         return ret_ref;
46272 }
46273
46274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
46275         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46276         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
46277         int64_t ret_ref = (uintptr_t)ret_copy;
46278         return ret_ref;
46279 }
46280
46281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
46282         
46283         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46284         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
46285         int64_t ret_ref = (uintptr_t)ret_copy;
46286         return ret_ref;
46287 }
46288
46289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
46290         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46291         *ret_copy = ParseError_padding_error();
46292         int64_t ret_ref = (uintptr_t)ret_copy;
46293         return ret_ref;
46294 }
46295
46296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
46297         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46298         *ret_copy = ParseError_integer_overflow_error();
46299         int64_t ret_ref = (uintptr_t)ret_copy;
46300         return ret_ref;
46301 }
46302
46303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
46304         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46305         *ret_copy = ParseError_invalid_seg_wit_program_length();
46306         int64_t ret_ref = (uintptr_t)ret_copy;
46307         return ret_ref;
46308 }
46309
46310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
46311         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46312         *ret_copy = ParseError_invalid_pub_key_hash_length();
46313         int64_t ret_ref = (uintptr_t)ret_copy;
46314         return ret_ref;
46315 }
46316
46317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
46318         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46319         *ret_copy = ParseError_invalid_script_hash_length();
46320         int64_t ret_ref = (uintptr_t)ret_copy;
46321         return ret_ref;
46322 }
46323
46324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
46325         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46326         *ret_copy = ParseError_invalid_recovery_id();
46327         int64_t ret_ref = (uintptr_t)ret_copy;
46328         return ret_ref;
46329 }
46330
46331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
46332         LDKStr a_conv = java_to_owned_str(env, a);
46333         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46334         *ret_copy = ParseError_invalid_slice_length(a_conv);
46335         int64_t ret_ref = (uintptr_t)ret_copy;
46336         return ret_ref;
46337 }
46338
46339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
46340         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46341         *ret_copy = ParseError_skip();
46342         int64_t ret_ref = (uintptr_t)ret_copy;
46343         return ret_ref;
46344 }
46345
46346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46347         if ((this_ptr & 1) != 0) return;
46348         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46349         CHECK_ACCESS(this_ptr_ptr);
46350         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
46351         FREE((void*)this_ptr);
46352         ParseOrSemanticError_free(this_ptr_conv);
46353 }
46354
46355 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
46356         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46357         *ret_copy = ParseOrSemanticError_clone(arg);
46358 int64_t ret_ref = (uintptr_t)ret_copy;
46359         return ret_ref;
46360 }
46361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46362         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
46363         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
46364         return ret_conv;
46365 }
46366
46367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46368         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
46369         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46370         *ret_copy = ParseOrSemanticError_clone(orig_conv);
46371         int64_t ret_ref = (uintptr_t)ret_copy;
46372         return ret_ref;
46373 }
46374
46375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
46376         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
46377         CHECK_ACCESS(a_ptr);
46378         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
46379         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
46380         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46381         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
46382         int64_t ret_ref = (uintptr_t)ret_copy;
46383         return ret_ref;
46384 }
46385
46386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
46387         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
46388         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46389         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
46390         int64_t ret_ref = (uintptr_t)ret_copy;
46391         return ret_ref;
46392 }
46393
46394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46395         LDKInvoice this_obj_conv;
46396         this_obj_conv.inner = (void*)(this_obj & (~1));
46397         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46399         Invoice_free(this_obj_conv);
46400 }
46401
46402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46403         LDKInvoice a_conv;
46404         a_conv.inner = (void*)(a & (~1));
46405         a_conv.is_owned = false;
46406         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46407         LDKInvoice b_conv;
46408         b_conv.inner = (void*)(b & (~1));
46409         b_conv.is_owned = false;
46410         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46411         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
46412         return ret_conv;
46413 }
46414
46415 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
46416         LDKInvoice ret_var = Invoice_clone(arg);
46417 int64_t ret_ref = 0;
46418 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46419 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46420 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46421 ret_ref = (uintptr_t)ret_var.inner;
46422 if (ret_var.is_owned) {
46423         ret_ref |= 1;
46424 }
46425         return ret_ref;
46426 }
46427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46428         LDKInvoice arg_conv;
46429         arg_conv.inner = (void*)(arg & (~1));
46430         arg_conv.is_owned = false;
46431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46432         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
46433         return ret_conv;
46434 }
46435
46436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46437         LDKInvoice orig_conv;
46438         orig_conv.inner = (void*)(orig & (~1));
46439         orig_conv.is_owned = false;
46440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46441         LDKInvoice ret_var = Invoice_clone(&orig_conv);
46442         int64_t ret_ref = 0;
46443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46446         ret_ref = (uintptr_t)ret_var.inner;
46447         if (ret_var.is_owned) {
46448                 ret_ref |= 1;
46449         }
46450         return ret_ref;
46451 }
46452
46453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46454         LDKSignedRawInvoice this_obj_conv;
46455         this_obj_conv.inner = (void*)(this_obj & (~1));
46456         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46458         SignedRawInvoice_free(this_obj_conv);
46459 }
46460
46461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46462         LDKSignedRawInvoice a_conv;
46463         a_conv.inner = (void*)(a & (~1));
46464         a_conv.is_owned = false;
46465         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46466         LDKSignedRawInvoice b_conv;
46467         b_conv.inner = (void*)(b & (~1));
46468         b_conv.is_owned = false;
46469         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46470         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
46471         return ret_conv;
46472 }
46473
46474 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
46475         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
46476 int64_t ret_ref = 0;
46477 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46478 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46479 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46480 ret_ref = (uintptr_t)ret_var.inner;
46481 if (ret_var.is_owned) {
46482         ret_ref |= 1;
46483 }
46484         return ret_ref;
46485 }
46486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46487         LDKSignedRawInvoice arg_conv;
46488         arg_conv.inner = (void*)(arg & (~1));
46489         arg_conv.is_owned = false;
46490         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46491         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
46492         return ret_conv;
46493 }
46494
46495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46496         LDKSignedRawInvoice orig_conv;
46497         orig_conv.inner = (void*)(orig & (~1));
46498         orig_conv.is_owned = false;
46499         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46500         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
46501         int64_t ret_ref = 0;
46502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46505         ret_ref = (uintptr_t)ret_var.inner;
46506         if (ret_var.is_owned) {
46507                 ret_ref |= 1;
46508         }
46509         return ret_ref;
46510 }
46511
46512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46513         LDKRawInvoice this_obj_conv;
46514         this_obj_conv.inner = (void*)(this_obj & (~1));
46515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46517         RawInvoice_free(this_obj_conv);
46518 }
46519
46520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
46521         LDKRawInvoice this_ptr_conv;
46522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46523         this_ptr_conv.is_owned = false;
46524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46525         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
46526         int64_t ret_ref = 0;
46527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46530         ret_ref = (uintptr_t)ret_var.inner;
46531         if (ret_var.is_owned) {
46532                 ret_ref |= 1;
46533         }
46534         return ret_ref;
46535 }
46536
46537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46538         LDKRawInvoice this_ptr_conv;
46539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46540         this_ptr_conv.is_owned = false;
46541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46542         LDKRawDataPart val_conv;
46543         val_conv.inner = (void*)(val & (~1));
46544         val_conv.is_owned = (val & 1) || (val == 0);
46545         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46546         val_conv = RawDataPart_clone(&val_conv);
46547         RawInvoice_set_data(&this_ptr_conv, val_conv);
46548 }
46549
46550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46551         LDKRawInvoice a_conv;
46552         a_conv.inner = (void*)(a & (~1));
46553         a_conv.is_owned = false;
46554         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46555         LDKRawInvoice b_conv;
46556         b_conv.inner = (void*)(b & (~1));
46557         b_conv.is_owned = false;
46558         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46559         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
46560         return ret_conv;
46561 }
46562
46563 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
46564         LDKRawInvoice ret_var = RawInvoice_clone(arg);
46565 int64_t ret_ref = 0;
46566 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46567 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46568 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46569 ret_ref = (uintptr_t)ret_var.inner;
46570 if (ret_var.is_owned) {
46571         ret_ref |= 1;
46572 }
46573         return ret_ref;
46574 }
46575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46576         LDKRawInvoice arg_conv;
46577         arg_conv.inner = (void*)(arg & (~1));
46578         arg_conv.is_owned = false;
46579         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46580         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
46581         return ret_conv;
46582 }
46583
46584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46585         LDKRawInvoice orig_conv;
46586         orig_conv.inner = (void*)(orig & (~1));
46587         orig_conv.is_owned = false;
46588         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46589         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
46590         int64_t ret_ref = 0;
46591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46594         ret_ref = (uintptr_t)ret_var.inner;
46595         if (ret_var.is_owned) {
46596                 ret_ref |= 1;
46597         }
46598         return ret_ref;
46599 }
46600
46601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46602         LDKRawDataPart this_obj_conv;
46603         this_obj_conv.inner = (void*)(this_obj & (~1));
46604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46606         RawDataPart_free(this_obj_conv);
46607 }
46608
46609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
46610         LDKRawDataPart this_ptr_conv;
46611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46612         this_ptr_conv.is_owned = false;
46613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46614         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
46615         int64_t ret_ref = 0;
46616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46619         ret_ref = (uintptr_t)ret_var.inner;
46620         if (ret_var.is_owned) {
46621                 ret_ref |= 1;
46622         }
46623         return ret_ref;
46624 }
46625
46626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46627         LDKRawDataPart this_ptr_conv;
46628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46629         this_ptr_conv.is_owned = false;
46630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46631         LDKPositiveTimestamp val_conv;
46632         val_conv.inner = (void*)(val & (~1));
46633         val_conv.is_owned = (val & 1) || (val == 0);
46634         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46635         val_conv = PositiveTimestamp_clone(&val_conv);
46636         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
46637 }
46638
46639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46640         LDKRawDataPart a_conv;
46641         a_conv.inner = (void*)(a & (~1));
46642         a_conv.is_owned = false;
46643         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46644         LDKRawDataPart b_conv;
46645         b_conv.inner = (void*)(b & (~1));
46646         b_conv.is_owned = false;
46647         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46648         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
46649         return ret_conv;
46650 }
46651
46652 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
46653         LDKRawDataPart ret_var = RawDataPart_clone(arg);
46654 int64_t ret_ref = 0;
46655 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46656 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46657 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46658 ret_ref = (uintptr_t)ret_var.inner;
46659 if (ret_var.is_owned) {
46660         ret_ref |= 1;
46661 }
46662         return ret_ref;
46663 }
46664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46665         LDKRawDataPart arg_conv;
46666         arg_conv.inner = (void*)(arg & (~1));
46667         arg_conv.is_owned = false;
46668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46669         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
46670         return ret_conv;
46671 }
46672
46673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46674         LDKRawDataPart orig_conv;
46675         orig_conv.inner = (void*)(orig & (~1));
46676         orig_conv.is_owned = false;
46677         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46678         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
46679         int64_t ret_ref = 0;
46680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46683         ret_ref = (uintptr_t)ret_var.inner;
46684         if (ret_var.is_owned) {
46685                 ret_ref |= 1;
46686         }
46687         return ret_ref;
46688 }
46689
46690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46691         LDKPositiveTimestamp this_obj_conv;
46692         this_obj_conv.inner = (void*)(this_obj & (~1));
46693         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46695         PositiveTimestamp_free(this_obj_conv);
46696 }
46697
46698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46699         LDKPositiveTimestamp a_conv;
46700         a_conv.inner = (void*)(a & (~1));
46701         a_conv.is_owned = false;
46702         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46703         LDKPositiveTimestamp b_conv;
46704         b_conv.inner = (void*)(b & (~1));
46705         b_conv.is_owned = false;
46706         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46707         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
46708         return ret_conv;
46709 }
46710
46711 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
46712         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
46713 int64_t ret_ref = 0;
46714 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46715 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46716 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46717 ret_ref = (uintptr_t)ret_var.inner;
46718 if (ret_var.is_owned) {
46719         ret_ref |= 1;
46720 }
46721         return ret_ref;
46722 }
46723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46724         LDKPositiveTimestamp arg_conv;
46725         arg_conv.inner = (void*)(arg & (~1));
46726         arg_conv.is_owned = false;
46727         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46728         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
46729         return ret_conv;
46730 }
46731
46732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46733         LDKPositiveTimestamp orig_conv;
46734         orig_conv.inner = (void*)(orig & (~1));
46735         orig_conv.is_owned = false;
46736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46737         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
46738         int64_t ret_ref = 0;
46739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46742         ret_ref = (uintptr_t)ret_var.inner;
46743         if (ret_var.is_owned) {
46744                 ret_ref |= 1;
46745         }
46746         return ret_ref;
46747 }
46748
46749 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46750         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
46751         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
46752         return ret_conv;
46753 }
46754
46755 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
46756         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
46757         return ret_conv;
46758 }
46759
46760 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
46761         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
46762         return ret_conv;
46763 }
46764
46765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
46766         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
46767         return ret_conv;
46768 }
46769
46770 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
46771         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
46772         return ret_conv;
46773 }
46774
46775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46776         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
46777         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
46778         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
46779         return ret_conv;
46780 }
46781
46782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
46783         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
46784         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
46785         return ret_conv;
46786 }
46787
46788 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46789         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
46790         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
46791         return ret_conv;
46792 }
46793
46794 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
46795         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
46796         return ret_conv;
46797 }
46798
46799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
46800         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
46801         return ret_conv;
46802 }
46803
46804 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
46805         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
46806         return ret_conv;
46807 }
46808
46809 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
46810         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
46811         return ret_conv;
46812 }
46813
46814 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
46815         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
46816         return ret_conv;
46817 }
46818
46819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
46820         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
46821         int64_t ret_conv = Currency_hash(o_conv);
46822         return ret_conv;
46823 }
46824
46825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46826         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
46827         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
46828         jboolean ret_conv = Currency_eq(a_conv, b_conv);
46829         return ret_conv;
46830 }
46831
46832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46833         LDKSha256 this_obj_conv;
46834         this_obj_conv.inner = (void*)(this_obj & (~1));
46835         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46837         Sha256_free(this_obj_conv);
46838 }
46839
46840 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
46841         LDKSha256 ret_var = Sha256_clone(arg);
46842 int64_t ret_ref = 0;
46843 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46844 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46845 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46846 ret_ref = (uintptr_t)ret_var.inner;
46847 if (ret_var.is_owned) {
46848         ret_ref |= 1;
46849 }
46850         return ret_ref;
46851 }
46852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46853         LDKSha256 arg_conv;
46854         arg_conv.inner = (void*)(arg & (~1));
46855         arg_conv.is_owned = false;
46856         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46857         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
46858         return ret_conv;
46859 }
46860
46861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46862         LDKSha256 orig_conv;
46863         orig_conv.inner = (void*)(orig & (~1));
46864         orig_conv.is_owned = false;
46865         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46866         LDKSha256 ret_var = Sha256_clone(&orig_conv);
46867         int64_t ret_ref = 0;
46868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46871         ret_ref = (uintptr_t)ret_var.inner;
46872         if (ret_var.is_owned) {
46873                 ret_ref |= 1;
46874         }
46875         return ret_ref;
46876 }
46877
46878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
46879         LDKSha256 o_conv;
46880         o_conv.inner = (void*)(o & (~1));
46881         o_conv.is_owned = false;
46882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46883         int64_t ret_conv = Sha256_hash(&o_conv);
46884         return ret_conv;
46885 }
46886
46887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46888         LDKSha256 a_conv;
46889         a_conv.inner = (void*)(a & (~1));
46890         a_conv.is_owned = false;
46891         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46892         LDKSha256 b_conv;
46893         b_conv.inner = (void*)(b & (~1));
46894         b_conv.is_owned = false;
46895         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46896         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
46897         return ret_conv;
46898 }
46899
46900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46901         LDKDescription this_obj_conv;
46902         this_obj_conv.inner = (void*)(this_obj & (~1));
46903         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46905         Description_free(this_obj_conv);
46906 }
46907
46908 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
46909         LDKDescription ret_var = Description_clone(arg);
46910 int64_t ret_ref = 0;
46911 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46912 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46913 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46914 ret_ref = (uintptr_t)ret_var.inner;
46915 if (ret_var.is_owned) {
46916         ret_ref |= 1;
46917 }
46918         return ret_ref;
46919 }
46920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46921         LDKDescription arg_conv;
46922         arg_conv.inner = (void*)(arg & (~1));
46923         arg_conv.is_owned = false;
46924         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46925         int64_t ret_conv = Description_clone_ptr(&arg_conv);
46926         return ret_conv;
46927 }
46928
46929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46930         LDKDescription orig_conv;
46931         orig_conv.inner = (void*)(orig & (~1));
46932         orig_conv.is_owned = false;
46933         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46934         LDKDescription ret_var = Description_clone(&orig_conv);
46935         int64_t ret_ref = 0;
46936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46939         ret_ref = (uintptr_t)ret_var.inner;
46940         if (ret_var.is_owned) {
46941                 ret_ref |= 1;
46942         }
46943         return ret_ref;
46944 }
46945
46946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
46947         LDKDescription o_conv;
46948         o_conv.inner = (void*)(o & (~1));
46949         o_conv.is_owned = false;
46950         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46951         int64_t ret_conv = Description_hash(&o_conv);
46952         return ret_conv;
46953 }
46954
46955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46956         LDKDescription a_conv;
46957         a_conv.inner = (void*)(a & (~1));
46958         a_conv.is_owned = false;
46959         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46960         LDKDescription b_conv;
46961         b_conv.inner = (void*)(b & (~1));
46962         b_conv.is_owned = false;
46963         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46964         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
46965         return ret_conv;
46966 }
46967
46968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46969         LDKPayeePubKey this_obj_conv;
46970         this_obj_conv.inner = (void*)(this_obj & (~1));
46971         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46973         PayeePubKey_free(this_obj_conv);
46974 }
46975
46976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46977         LDKPayeePubKey this_ptr_conv;
46978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46979         this_ptr_conv.is_owned = false;
46980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46981         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
46983         return ret_arr;
46984 }
46985
46986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46987         LDKPayeePubKey this_ptr_conv;
46988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46989         this_ptr_conv.is_owned = false;
46990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46991         LDKPublicKey val_ref;
46992         CHECK((*env)->GetArrayLength(env, val) == 33);
46993         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46994         PayeePubKey_set_a(&this_ptr_conv, val_ref);
46995 }
46996
46997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
46998         LDKPublicKey a_arg_ref;
46999         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
47000         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
47001         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
47002         int64_t ret_ref = 0;
47003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47006         ret_ref = (uintptr_t)ret_var.inner;
47007         if (ret_var.is_owned) {
47008                 ret_ref |= 1;
47009         }
47010         return ret_ref;
47011 }
47012
47013 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
47014         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
47015 int64_t ret_ref = 0;
47016 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47017 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47018 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47019 ret_ref = (uintptr_t)ret_var.inner;
47020 if (ret_var.is_owned) {
47021         ret_ref |= 1;
47022 }
47023         return ret_ref;
47024 }
47025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47026         LDKPayeePubKey arg_conv;
47027         arg_conv.inner = (void*)(arg & (~1));
47028         arg_conv.is_owned = false;
47029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47030         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
47031         return ret_conv;
47032 }
47033
47034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47035         LDKPayeePubKey orig_conv;
47036         orig_conv.inner = (void*)(orig & (~1));
47037         orig_conv.is_owned = false;
47038         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47039         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
47040         int64_t ret_ref = 0;
47041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47044         ret_ref = (uintptr_t)ret_var.inner;
47045         if (ret_var.is_owned) {
47046                 ret_ref |= 1;
47047         }
47048         return ret_ref;
47049 }
47050
47051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
47052         LDKPayeePubKey o_conv;
47053         o_conv.inner = (void*)(o & (~1));
47054         o_conv.is_owned = false;
47055         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47056         int64_t ret_conv = PayeePubKey_hash(&o_conv);
47057         return ret_conv;
47058 }
47059
47060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47061         LDKPayeePubKey a_conv;
47062         a_conv.inner = (void*)(a & (~1));
47063         a_conv.is_owned = false;
47064         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47065         LDKPayeePubKey b_conv;
47066         b_conv.inner = (void*)(b & (~1));
47067         b_conv.is_owned = false;
47068         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47069         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
47070         return ret_conv;
47071 }
47072
47073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47074         LDKExpiryTime this_obj_conv;
47075         this_obj_conv.inner = (void*)(this_obj & (~1));
47076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47078         ExpiryTime_free(this_obj_conv);
47079 }
47080
47081 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
47082         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
47083 int64_t ret_ref = 0;
47084 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47085 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47086 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47087 ret_ref = (uintptr_t)ret_var.inner;
47088 if (ret_var.is_owned) {
47089         ret_ref |= 1;
47090 }
47091         return ret_ref;
47092 }
47093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47094         LDKExpiryTime arg_conv;
47095         arg_conv.inner = (void*)(arg & (~1));
47096         arg_conv.is_owned = false;
47097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47098         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
47099         return ret_conv;
47100 }
47101
47102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47103         LDKExpiryTime orig_conv;
47104         orig_conv.inner = (void*)(orig & (~1));
47105         orig_conv.is_owned = false;
47106         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47107         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
47108         int64_t ret_ref = 0;
47109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47112         ret_ref = (uintptr_t)ret_var.inner;
47113         if (ret_var.is_owned) {
47114                 ret_ref |= 1;
47115         }
47116         return ret_ref;
47117 }
47118
47119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
47120         LDKExpiryTime o_conv;
47121         o_conv.inner = (void*)(o & (~1));
47122         o_conv.is_owned = false;
47123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47124         int64_t ret_conv = ExpiryTime_hash(&o_conv);
47125         return ret_conv;
47126 }
47127
47128 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47129         LDKExpiryTime a_conv;
47130         a_conv.inner = (void*)(a & (~1));
47131         a_conv.is_owned = false;
47132         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47133         LDKExpiryTime b_conv;
47134         b_conv.inner = (void*)(b & (~1));
47135         b_conv.is_owned = false;
47136         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47137         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
47138         return ret_conv;
47139 }
47140
47141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47142         LDKMinFinalCltvExpiry this_obj_conv;
47143         this_obj_conv.inner = (void*)(this_obj & (~1));
47144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47146         MinFinalCltvExpiry_free(this_obj_conv);
47147 }
47148
47149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47150         LDKMinFinalCltvExpiry this_ptr_conv;
47151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47152         this_ptr_conv.is_owned = false;
47153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47154         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
47155         return ret_conv;
47156 }
47157
47158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47159         LDKMinFinalCltvExpiry this_ptr_conv;
47160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47161         this_ptr_conv.is_owned = false;
47162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47163         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
47164 }
47165
47166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
47167         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
47168         int64_t ret_ref = 0;
47169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47172         ret_ref = (uintptr_t)ret_var.inner;
47173         if (ret_var.is_owned) {
47174                 ret_ref |= 1;
47175         }
47176         return ret_ref;
47177 }
47178
47179 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
47180         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
47181 int64_t ret_ref = 0;
47182 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47183 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47184 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47185 ret_ref = (uintptr_t)ret_var.inner;
47186 if (ret_var.is_owned) {
47187         ret_ref |= 1;
47188 }
47189         return ret_ref;
47190 }
47191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47192         LDKMinFinalCltvExpiry arg_conv;
47193         arg_conv.inner = (void*)(arg & (~1));
47194         arg_conv.is_owned = false;
47195         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47196         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
47197         return ret_conv;
47198 }
47199
47200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47201         LDKMinFinalCltvExpiry orig_conv;
47202         orig_conv.inner = (void*)(orig & (~1));
47203         orig_conv.is_owned = false;
47204         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47205         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
47206         int64_t ret_ref = 0;
47207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47210         ret_ref = (uintptr_t)ret_var.inner;
47211         if (ret_var.is_owned) {
47212                 ret_ref |= 1;
47213         }
47214         return ret_ref;
47215 }
47216
47217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47218         LDKMinFinalCltvExpiry o_conv;
47219         o_conv.inner = (void*)(o & (~1));
47220         o_conv.is_owned = false;
47221         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47222         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
47223         return ret_conv;
47224 }
47225
47226 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47227         LDKMinFinalCltvExpiry a_conv;
47228         a_conv.inner = (void*)(a & (~1));
47229         a_conv.is_owned = false;
47230         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47231         LDKMinFinalCltvExpiry b_conv;
47232         b_conv.inner = (void*)(b & (~1));
47233         b_conv.is_owned = false;
47234         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47235         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
47236         return ret_conv;
47237 }
47238
47239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47240         if ((this_ptr & 1) != 0) return;
47241         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47242         CHECK_ACCESS(this_ptr_ptr);
47243         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
47244         FREE((void*)this_ptr);
47245         Fallback_free(this_ptr_conv);
47246 }
47247
47248 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
47249         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47250         *ret_copy = Fallback_clone(arg);
47251 int64_t ret_ref = (uintptr_t)ret_copy;
47252         return ret_ref;
47253 }
47254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47255         LDKFallback* arg_conv = (LDKFallback*)arg;
47256         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
47257         return ret_conv;
47258 }
47259
47260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47261         LDKFallback* orig_conv = (LDKFallback*)orig;
47262         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47263         *ret_copy = Fallback_clone(orig_conv);
47264         int64_t ret_ref = (uintptr_t)ret_copy;
47265         return ret_ref;
47266 }
47267
47268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
47269         
47270         LDKCVec_u8Z program_ref;
47271         program_ref.datalen = (*env)->GetArrayLength(env, program);
47272         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
47273         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
47274         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47275         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
47276         int64_t ret_ref = (uintptr_t)ret_copy;
47277         return ret_ref;
47278 }
47279
47280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
47281         LDKTwentyBytes a_ref;
47282         CHECK((*env)->GetArrayLength(env, a) == 20);
47283         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
47284         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47285         *ret_copy = Fallback_pub_key_hash(a_ref);
47286         int64_t ret_ref = (uintptr_t)ret_copy;
47287         return ret_ref;
47288 }
47289
47290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
47291         LDKTwentyBytes a_ref;
47292         CHECK((*env)->GetArrayLength(env, a) == 20);
47293         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
47294         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47295         *ret_copy = Fallback_script_hash(a_ref);
47296         int64_t ret_ref = (uintptr_t)ret_copy;
47297         return ret_ref;
47298 }
47299
47300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
47301         LDKFallback* o_conv = (LDKFallback*)o;
47302         int64_t ret_conv = Fallback_hash(o_conv);
47303         return ret_conv;
47304 }
47305
47306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47307         LDKFallback* a_conv = (LDKFallback*)a;
47308         LDKFallback* b_conv = (LDKFallback*)b;
47309         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
47310         return ret_conv;
47311 }
47312
47313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47314         LDKInvoiceSignature this_obj_conv;
47315         this_obj_conv.inner = (void*)(this_obj & (~1));
47316         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47318         InvoiceSignature_free(this_obj_conv);
47319 }
47320
47321 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
47322         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
47323 int64_t ret_ref = 0;
47324 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47325 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47326 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47327 ret_ref = (uintptr_t)ret_var.inner;
47328 if (ret_var.is_owned) {
47329         ret_ref |= 1;
47330 }
47331         return ret_ref;
47332 }
47333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47334         LDKInvoiceSignature arg_conv;
47335         arg_conv.inner = (void*)(arg & (~1));
47336         arg_conv.is_owned = false;
47337         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47338         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
47339         return ret_conv;
47340 }
47341
47342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47343         LDKInvoiceSignature orig_conv;
47344         orig_conv.inner = (void*)(orig & (~1));
47345         orig_conv.is_owned = false;
47346         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47347         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
47348         int64_t ret_ref = 0;
47349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47352         ret_ref = (uintptr_t)ret_var.inner;
47353         if (ret_var.is_owned) {
47354                 ret_ref |= 1;
47355         }
47356         return ret_ref;
47357 }
47358
47359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47360         LDKInvoiceSignature a_conv;
47361         a_conv.inner = (void*)(a & (~1));
47362         a_conv.is_owned = false;
47363         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47364         LDKInvoiceSignature b_conv;
47365         b_conv.inner = (void*)(b & (~1));
47366         b_conv.is_owned = false;
47367         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47368         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
47369         return ret_conv;
47370 }
47371
47372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47373         LDKPrivateRoute this_obj_conv;
47374         this_obj_conv.inner = (void*)(this_obj & (~1));
47375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47377         PrivateRoute_free(this_obj_conv);
47378 }
47379
47380 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
47381         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
47382 int64_t ret_ref = 0;
47383 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47384 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47385 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47386 ret_ref = (uintptr_t)ret_var.inner;
47387 if (ret_var.is_owned) {
47388         ret_ref |= 1;
47389 }
47390         return ret_ref;
47391 }
47392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47393         LDKPrivateRoute arg_conv;
47394         arg_conv.inner = (void*)(arg & (~1));
47395         arg_conv.is_owned = false;
47396         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47397         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
47398         return ret_conv;
47399 }
47400
47401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47402         LDKPrivateRoute orig_conv;
47403         orig_conv.inner = (void*)(orig & (~1));
47404         orig_conv.is_owned = false;
47405         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47406         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
47407         int64_t ret_ref = 0;
47408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47411         ret_ref = (uintptr_t)ret_var.inner;
47412         if (ret_var.is_owned) {
47413                 ret_ref |= 1;
47414         }
47415         return ret_ref;
47416 }
47417
47418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
47419         LDKPrivateRoute o_conv;
47420         o_conv.inner = (void*)(o & (~1));
47421         o_conv.is_owned = false;
47422         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47423         int64_t ret_conv = PrivateRoute_hash(&o_conv);
47424         return ret_conv;
47425 }
47426
47427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47428         LDKPrivateRoute a_conv;
47429         a_conv.inner = (void*)(a & (~1));
47430         a_conv.is_owned = false;
47431         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47432         LDKPrivateRoute b_conv;
47433         b_conv.inner = (void*)(b & (~1));
47434         b_conv.is_owned = false;
47435         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47436         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
47437         return ret_conv;
47438 }
47439
47440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
47441         LDKSignedRawInvoice this_arg_conv;
47442         this_arg_conv.inner = (void*)(this_arg & (~1));
47443         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47445         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
47446         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
47447         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
47448         return ((int64_t)ret_conv);
47449 }
47450
47451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
47452         LDKSignedRawInvoice this_arg_conv;
47453         this_arg_conv.inner = (void*)(this_arg & (~1));
47454         this_arg_conv.is_owned = false;
47455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47456         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
47457         int64_t ret_ref = 0;
47458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47461         ret_ref = (uintptr_t)ret_var.inner;
47462         if (ret_var.is_owned) {
47463                 ret_ref |= 1;
47464         }
47465         return ret_ref;
47466 }
47467
47468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47469         LDKSignedRawInvoice this_arg_conv;
47470         this_arg_conv.inner = (void*)(this_arg & (~1));
47471         this_arg_conv.is_owned = false;
47472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47473         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47474         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
47475         return ret_arr;
47476 }
47477
47478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47479         LDKSignedRawInvoice this_arg_conv;
47480         this_arg_conv.inner = (void*)(this_arg & (~1));
47481         this_arg_conv.is_owned = false;
47482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47483         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
47484         int64_t ret_ref = 0;
47485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47488         ret_ref = (uintptr_t)ret_var.inner;
47489         if (ret_var.is_owned) {
47490                 ret_ref |= 1;
47491         }
47492         return ret_ref;
47493 }
47494
47495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47496         LDKSignedRawInvoice this_arg_conv;
47497         this_arg_conv.inner = (void*)(this_arg & (~1));
47498         this_arg_conv.is_owned = false;
47499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47500         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
47501         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
47502         return (int64_t)ret_conv;
47503 }
47504
47505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47506         LDKSignedRawInvoice this_arg_conv;
47507         this_arg_conv.inner = (void*)(this_arg & (~1));
47508         this_arg_conv.is_owned = false;
47509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47510         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
47511         return ret_conv;
47512 }
47513
47514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47515         LDKRawInvoice this_arg_conv;
47516         this_arg_conv.inner = (void*)(this_arg & (~1));
47517         this_arg_conv.is_owned = false;
47518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47519         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
47521         return ret_arr;
47522 }
47523
47524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47525         LDKRawInvoice this_arg_conv;
47526         this_arg_conv.inner = (void*)(this_arg & (~1));
47527         this_arg_conv.is_owned = false;
47528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47529         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
47530         int64_t ret_ref = 0;
47531         if ((uintptr_t)ret_var.inner > 4096) {
47532                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47533                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47535                 ret_ref = (uintptr_t)ret_var.inner;
47536                 if (ret_var.is_owned) {
47537                         ret_ref |= 1;
47538                 }
47539         }
47540         return ret_ref;
47541 }
47542
47543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
47544         LDKRawInvoice this_arg_conv;
47545         this_arg_conv.inner = (void*)(this_arg & (~1));
47546         this_arg_conv.is_owned = false;
47547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47548         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
47549         int64_t ret_ref = 0;
47550         if ((uintptr_t)ret_var.inner > 4096) {
47551                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47552                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47554                 ret_ref = (uintptr_t)ret_var.inner;
47555                 if (ret_var.is_owned) {
47556                         ret_ref |= 1;
47557                 }
47558         }
47559         return ret_ref;
47560 }
47561
47562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47563         LDKRawInvoice this_arg_conv;
47564         this_arg_conv.inner = (void*)(this_arg & (~1));
47565         this_arg_conv.is_owned = false;
47566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47567         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
47568         int64_t ret_ref = 0;
47569         if ((uintptr_t)ret_var.inner > 4096) {
47570                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47571                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47573                 ret_ref = (uintptr_t)ret_var.inner;
47574                 if (ret_var.is_owned) {
47575                         ret_ref |= 1;
47576                 }
47577         }
47578         return ret_ref;
47579 }
47580
47581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47582         LDKRawInvoice this_arg_conv;
47583         this_arg_conv.inner = (void*)(this_arg & (~1));
47584         this_arg_conv.is_owned = false;
47585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47586         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
47587         int64_t ret_ref = 0;
47588         if ((uintptr_t)ret_var.inner > 4096) {
47589                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47590                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47592                 ret_ref = (uintptr_t)ret_var.inner;
47593                 if (ret_var.is_owned) {
47594                         ret_ref |= 1;
47595                 }
47596         }
47597         return ret_ref;
47598 }
47599
47600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47601         LDKRawInvoice this_arg_conv;
47602         this_arg_conv.inner = (void*)(this_arg & (~1));
47603         this_arg_conv.is_owned = false;
47604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47605         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
47606         int64_t ret_ref = 0;
47607         if ((uintptr_t)ret_var.inner > 4096) {
47608                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47609                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47611                 ret_ref = (uintptr_t)ret_var.inner;
47612                 if (ret_var.is_owned) {
47613                         ret_ref |= 1;
47614                 }
47615         }
47616         return ret_ref;
47617 }
47618
47619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47620         LDKRawInvoice this_arg_conv;
47621         this_arg_conv.inner = (void*)(this_arg & (~1));
47622         this_arg_conv.is_owned = false;
47623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47624         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
47625         int64_t ret_ref = 0;
47626         if ((uintptr_t)ret_var.inner > 4096) {
47627                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47628                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47630                 ret_ref = (uintptr_t)ret_var.inner;
47631                 if (ret_var.is_owned) {
47632                         ret_ref |= 1;
47633                 }
47634         }
47635         return ret_ref;
47636 }
47637
47638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
47639         LDKRawInvoice this_arg_conv;
47640         this_arg_conv.inner = (void*)(this_arg & (~1));
47641         this_arg_conv.is_owned = false;
47642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47643         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
47645         return ret_arr;
47646 }
47647
47648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47649         LDKRawInvoice this_arg_conv;
47650         this_arg_conv.inner = (void*)(this_arg & (~1));
47651         this_arg_conv.is_owned = false;
47652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47653         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
47654         int64_t ret_ref = 0;
47655         if ((uintptr_t)ret_var.inner > 4096) {
47656                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47657                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47659                 ret_ref = (uintptr_t)ret_var.inner;
47660                 if (ret_var.is_owned) {
47661                         ret_ref |= 1;
47662                 }
47663         }
47664         return ret_ref;
47665 }
47666
47667 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47668         LDKRawInvoice this_arg_conv;
47669         this_arg_conv.inner = (void*)(this_arg & (~1));
47670         this_arg_conv.is_owned = false;
47671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47672         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
47673         int64_tArray ret_arr = NULL;
47674         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47675         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47676         for (size_t o = 0; o < ret_var.datalen; o++) {
47677                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47678                 int64_t ret_conv_14_ref = 0;
47679                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47680                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47681                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47682                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
47683                 if (ret_conv_14_var.is_owned) {
47684                         ret_conv_14_ref |= 1;
47685                 }
47686                 ret_arr_ptr[o] = ret_conv_14_ref;
47687         }
47688         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47689         FREE(ret_var.data);
47690         return ret_arr;
47691 }
47692
47693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
47694         LDKRawInvoice this_arg_conv;
47695         this_arg_conv.inner = (void*)(this_arg & (~1));
47696         this_arg_conv.is_owned = false;
47697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47698         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47699         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
47700         int64_t ret_ref = (uintptr_t)ret_copy;
47701         return ret_ref;
47702 }
47703
47704 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47705         LDKRawInvoice this_arg_conv;
47706         this_arg_conv.inner = (void*)(this_arg & (~1));
47707         this_arg_conv.is_owned = false;
47708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47709         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
47710         return ret_conv;
47711 }
47712
47713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
47714         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47715         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
47716         return (int64_t)ret_conv;
47717 }
47718
47719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
47720         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47721         *ret_conv = PositiveTimestamp_from_system_time(time);
47722         return (int64_t)ret_conv;
47723 }
47724
47725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
47726         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47727         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
47728         return (int64_t)ret_conv;
47729 }
47730
47731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47732         LDKPositiveTimestamp this_arg_conv;
47733         this_arg_conv.inner = (void*)(this_arg & (~1));
47734         this_arg_conv.is_owned = false;
47735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47736         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
47737         return ret_conv;
47738 }
47739
47740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
47741         LDKPositiveTimestamp this_arg_conv;
47742         this_arg_conv.inner = (void*)(this_arg & (~1));
47743         this_arg_conv.is_owned = false;
47744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47745         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
47746         return ret_conv;
47747 }
47748
47749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47750         LDKPositiveTimestamp this_arg_conv;
47751         this_arg_conv.inner = (void*)(this_arg & (~1));
47752         this_arg_conv.is_owned = false;
47753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47754         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
47755         return ret_conv;
47756 }
47757
47758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
47759         LDKInvoice this_arg_conv;
47760         this_arg_conv.inner = (void*)(this_arg & (~1));
47761         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47763         this_arg_conv = Invoice_clone(&this_arg_conv);
47764         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
47765         int64_t ret_ref = 0;
47766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47769         ret_ref = (uintptr_t)ret_var.inner;
47770         if (ret_var.is_owned) {
47771                 ret_ref |= 1;
47772         }
47773         return ret_ref;
47774 }
47775
47776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47777         LDKInvoice this_arg_conv;
47778         this_arg_conv.inner = (void*)(this_arg & (~1));
47779         this_arg_conv.is_owned = false;
47780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47781         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
47782         *ret_conv = Invoice_check_signature(&this_arg_conv);
47783         return (int64_t)ret_conv;
47784 }
47785
47786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
47787         LDKSignedRawInvoice signed_invoice_conv;
47788         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
47789         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
47790         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
47791         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
47792         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
47793         *ret_conv = Invoice_from_signed(signed_invoice_conv);
47794         return (int64_t)ret_conv;
47795 }
47796
47797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47798         LDKInvoice this_arg_conv;
47799         this_arg_conv.inner = (void*)(this_arg & (~1));
47800         this_arg_conv.is_owned = false;
47801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47802         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
47803         return ret_conv;
47804 }
47805
47806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
47807         LDKInvoice this_arg_conv;
47808         this_arg_conv.inner = (void*)(this_arg & (~1));
47809         this_arg_conv.is_owned = false;
47810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47811         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
47812         return ret_conv;
47813 }
47814
47815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47816         LDKInvoice this_arg_conv;
47817         this_arg_conv.inner = (void*)(this_arg & (~1));
47818         this_arg_conv.is_owned = false;
47819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47820         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
47822         return ret_arr;
47823 }
47824
47825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47826         LDKInvoice this_arg_conv;
47827         this_arg_conv.inner = (void*)(this_arg & (~1));
47828         this_arg_conv.is_owned = false;
47829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47830         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
47832         return ret_arr;
47833 }
47834
47835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
47836         LDKInvoice this_arg_conv;
47837         this_arg_conv.inner = (void*)(this_arg & (~1));
47838         this_arg_conv.is_owned = false;
47839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47840         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
47842         return ret_arr;
47843 }
47844
47845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47846         LDKInvoice this_arg_conv;
47847         this_arg_conv.inner = (void*)(this_arg & (~1));
47848         this_arg_conv.is_owned = false;
47849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47850         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
47851         int64_t ret_ref = 0;
47852         if ((uintptr_t)ret_var.inner > 4096) {
47853                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47854                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47856                 ret_ref = (uintptr_t)ret_var.inner;
47857                 if (ret_var.is_owned) {
47858                         ret_ref |= 1;
47859                 }
47860         }
47861         return ret_ref;
47862 }
47863
47864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47865         LDKInvoice this_arg_conv;
47866         this_arg_conv.inner = (void*)(this_arg & (~1));
47867         this_arg_conv.is_owned = false;
47868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47869         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
47871         return ret_arr;
47872 }
47873
47874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47875         LDKInvoice this_arg_conv;
47876         this_arg_conv.inner = (void*)(this_arg & (~1));
47877         this_arg_conv.is_owned = false;
47878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47879         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
47880         return ret_conv;
47881 }
47882
47883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47884         LDKInvoice this_arg_conv;
47885         this_arg_conv.inner = (void*)(this_arg & (~1));
47886         this_arg_conv.is_owned = false;
47887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47888         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
47889         return ret_conv;
47890 }
47891
47892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
47893         LDKInvoice this_arg_conv;
47894         this_arg_conv.inner = (void*)(this_arg & (~1));
47895         this_arg_conv.is_owned = false;
47896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47897         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
47898         return ret_conv;
47899 }
47900
47901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47902         LDKInvoice this_arg_conv;
47903         this_arg_conv.inner = (void*)(this_arg & (~1));
47904         this_arg_conv.is_owned = false;
47905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47906         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
47907         return ret_conv;
47908 }
47909
47910 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47911         LDKInvoice this_arg_conv;
47912         this_arg_conv.inner = (void*)(this_arg & (~1));
47913         this_arg_conv.is_owned = false;
47914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47915         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
47916         int64_tArray ret_arr = NULL;
47917         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47918         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47919         for (size_t o = 0; o < ret_var.datalen; o++) {
47920                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47921                 int64_t ret_conv_14_ref = 0;
47922                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47923                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47924                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47925                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
47926                 if (ret_conv_14_var.is_owned) {
47927                         ret_conv_14_ref |= 1;
47928                 }
47929                 ret_arr_ptr[o] = ret_conv_14_ref;
47930         }
47931         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47932         FREE(ret_var.data);
47933         return ret_arr;
47934 }
47935
47936 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
47937         LDKInvoice this_arg_conv;
47938         this_arg_conv.inner = (void*)(this_arg & (~1));
47939         this_arg_conv.is_owned = false;
47940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47941         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
47942         int64_tArray ret_arr = NULL;
47943         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47944         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47945         for (size_t l = 0; l < ret_var.datalen; l++) {
47946                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
47947                 int64_t ret_conv_11_ref = 0;
47948                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47949                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47950                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
47951                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
47952                 if (ret_conv_11_var.is_owned) {
47953                         ret_conv_11_ref |= 1;
47954                 }
47955                 ret_arr_ptr[l] = ret_conv_11_ref;
47956         }
47957         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47958         FREE(ret_var.data);
47959         return ret_arr;
47960 }
47961
47962 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47963         LDKInvoice this_arg_conv;
47964         this_arg_conv.inner = (void*)(this_arg & (~1));
47965         this_arg_conv.is_owned = false;
47966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47967         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
47968         return ret_conv;
47969 }
47970
47971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
47972         LDKInvoice this_arg_conv;
47973         this_arg_conv.inner = (void*)(this_arg & (~1));
47974         this_arg_conv.is_owned = false;
47975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47976         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47977         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
47978         int64_t ret_ref = (uintptr_t)ret_copy;
47979         return ret_ref;
47980 }
47981
47982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
47983         LDKStr description_conv = java_to_owned_str(env, description);
47984         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
47985         *ret_conv = Description_new(description_conv);
47986         return (int64_t)ret_conv;
47987 }
47988
47989 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
47990         LDKDescription this_arg_conv;
47991         this_arg_conv.inner = (void*)(this_arg & (~1));
47992         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47994         this_arg_conv = Description_clone(&this_arg_conv);
47995         LDKStr ret_str = Description_into_inner(this_arg_conv);
47996         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47997         Str_free(ret_str);
47998         return ret_conv;
47999 }
48000
48001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
48002         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
48003         int64_t ret_ref = 0;
48004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48007         ret_ref = (uintptr_t)ret_var.inner;
48008         if (ret_var.is_owned) {
48009                 ret_ref |= 1;
48010         }
48011         return ret_ref;
48012 }
48013
48014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
48015         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
48016         int64_t ret_ref = 0;
48017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48020         ret_ref = (uintptr_t)ret_var.inner;
48021         if (ret_var.is_owned) {
48022                 ret_ref |= 1;
48023         }
48024         return ret_ref;
48025 }
48026
48027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
48028         LDKExpiryTime this_arg_conv;
48029         this_arg_conv.inner = (void*)(this_arg & (~1));
48030         this_arg_conv.is_owned = false;
48031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48032         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
48033         return ret_conv;
48034 }
48035
48036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
48037         LDKExpiryTime this_arg_conv;
48038         this_arg_conv.inner = (void*)(this_arg & (~1));
48039         this_arg_conv.is_owned = false;
48040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48041         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
48042         return ret_conv;
48043 }
48044
48045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
48046         LDKRouteHint hops_conv;
48047         hops_conv.inner = (void*)(hops & (~1));
48048         hops_conv.is_owned = (hops & 1) || (hops == 0);
48049         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
48050         hops_conv = RouteHint_clone(&hops_conv);
48051         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
48052         *ret_conv = PrivateRoute_new(hops_conv);
48053         return (int64_t)ret_conv;
48054 }
48055
48056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
48057         LDKPrivateRoute this_arg_conv;
48058         this_arg_conv.inner = (void*)(this_arg & (~1));
48059         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48061         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
48062         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
48063         int64_t ret_ref = 0;
48064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48067         ret_ref = (uintptr_t)ret_var.inner;
48068         if (ret_var.is_owned) {
48069                 ret_ref |= 1;
48070         }
48071         return ret_ref;
48072 }
48073
48074 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48075         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
48076         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
48077         return ret_conv;
48078 }
48079
48080 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
48081         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
48082         return ret_conv;
48083 }
48084
48085 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
48086         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
48087         return ret_conv;
48088 }
48089
48090 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
48091         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
48092         return ret_conv;
48093 }
48094
48095 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
48096         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
48097         return ret_conv;
48098 }
48099
48100 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
48101         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
48102         return ret_conv;
48103 }
48104
48105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48106         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
48107         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
48108         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
48109         return ret_conv;
48110 }
48111
48112 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48113         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
48114         LDKStr ret_str = CreationError_to_str(o_conv);
48115         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48116         Str_free(ret_str);
48117         return ret_conv;
48118 }
48119
48120 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48121         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
48122         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
48123         return ret_conv;
48124 }
48125
48126 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
48127         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
48128         return ret_conv;
48129 }
48130
48131 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
48132         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
48133         return ret_conv;
48134 }
48135
48136 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
48137         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
48138         return ret_conv;
48139 }
48140
48141 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
48142         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
48143         return ret_conv;
48144 }
48145
48146 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
48147         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
48148         return ret_conv;
48149 }
48150
48151 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
48152         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
48153         return ret_conv;
48154 }
48155
48156 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
48157         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
48158         return ret_conv;
48159 }
48160
48161 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
48162         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
48163         return ret_conv;
48164 }
48165
48166 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
48167         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
48168         return ret_conv;
48169 }
48170
48171 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
48172         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
48173         return ret_conv;
48174 }
48175
48176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48177         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
48178         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
48179         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
48180         return ret_conv;
48181 }
48182
48183 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48184         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
48185         LDKStr ret_str = SemanticError_to_str(o_conv);
48186         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48187         Str_free(ret_str);
48188         return ret_conv;
48189 }
48190
48191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48192         if ((this_ptr & 1) != 0) return;
48193         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48194         CHECK_ACCESS(this_ptr_ptr);
48195         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
48196         FREE((void*)this_ptr);
48197         SignOrCreationError_free(this_ptr_conv);
48198 }
48199
48200 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
48201         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48202         *ret_copy = SignOrCreationError_clone(arg);
48203 int64_t ret_ref = (uintptr_t)ret_copy;
48204         return ret_ref;
48205 }
48206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48207         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
48208         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
48209         return ret_conv;
48210 }
48211
48212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48213         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
48214         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48215         *ret_copy = SignOrCreationError_clone(orig_conv);
48216         int64_t ret_ref = (uintptr_t)ret_copy;
48217         return ret_ref;
48218 }
48219
48220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
48221         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48222         *ret_copy = SignOrCreationError_sign_error();
48223         int64_t ret_ref = (uintptr_t)ret_copy;
48224         return ret_ref;
48225 }
48226
48227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
48228         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
48229         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48230         *ret_copy = SignOrCreationError_creation_error(a_conv);
48231         int64_t ret_ref = (uintptr_t)ret_copy;
48232         return ret_ref;
48233 }
48234
48235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48236         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
48237         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
48238         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
48239         return ret_conv;
48240 }
48241
48242 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48243         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
48244         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
48245         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48246         Str_free(ret_str);
48247         return ret_conv;
48248 }
48249
48250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48251         LDKInvoicePayer this_obj_conv;
48252         this_obj_conv.inner = (void*)(this_obj & (~1));
48253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48255         InvoicePayer_free(this_obj_conv);
48256 }
48257
48258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48259         if ((this_ptr & 1) != 0) return;
48260         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48261         CHECK_ACCESS(this_ptr_ptr);
48262         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
48263         FREE((void*)this_ptr);
48264         Payer_free(this_ptr_conv);
48265 }
48266
48267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48268         if ((this_ptr & 1) != 0) return;
48269         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48270         CHECK_ACCESS(this_ptr_ptr);
48271         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
48272         FREE((void*)this_ptr);
48273         Router_free(this_ptr_conv);
48274 }
48275
48276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48277         if ((this_ptr & 1) != 0) return;
48278         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48279         CHECK_ACCESS(this_ptr_ptr);
48280         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
48281         FREE((void*)this_ptr);
48282         Retry_free(this_ptr_conv);
48283 }
48284
48285 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
48286         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48287         *ret_copy = Retry_clone(arg);
48288 int64_t ret_ref = (uintptr_t)ret_copy;
48289         return ret_ref;
48290 }
48291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48292         LDKRetry* arg_conv = (LDKRetry*)arg;
48293         int64_t ret_conv = Retry_clone_ptr(arg_conv);
48294         return ret_conv;
48295 }
48296
48297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48298         LDKRetry* orig_conv = (LDKRetry*)orig;
48299         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48300         *ret_copy = Retry_clone(orig_conv);
48301         int64_t ret_ref = (uintptr_t)ret_copy;
48302         return ret_ref;
48303 }
48304
48305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
48306         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48307         *ret_copy = Retry_attempts(a);
48308         int64_t ret_ref = (uintptr_t)ret_copy;
48309         return ret_ref;
48310 }
48311
48312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
48313         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48314         *ret_copy = Retry_timeout(a);
48315         int64_t ret_ref = (uintptr_t)ret_copy;
48316         return ret_ref;
48317 }
48318
48319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48320         LDKRetry* a_conv = (LDKRetry*)a;
48321         LDKRetry* b_conv = (LDKRetry*)b;
48322         jboolean ret_conv = Retry_eq(a_conv, b_conv);
48323         return ret_conv;
48324 }
48325
48326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48327         LDKRetry* o_conv = (LDKRetry*)o;
48328         int64_t ret_conv = Retry_hash(o_conv);
48329         return ret_conv;
48330 }
48331
48332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48333         if ((this_ptr & 1) != 0) return;
48334         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48335         CHECK_ACCESS(this_ptr_ptr);
48336         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
48337         FREE((void*)this_ptr);
48338         PaymentError_free(this_ptr_conv);
48339 }
48340
48341 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
48342         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48343         *ret_copy = PaymentError_clone(arg);
48344 int64_t ret_ref = (uintptr_t)ret_copy;
48345         return ret_ref;
48346 }
48347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48348         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
48349         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
48350         return ret_conv;
48351 }
48352
48353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48354         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
48355         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48356         *ret_copy = PaymentError_clone(orig_conv);
48357         int64_t ret_ref = (uintptr_t)ret_copy;
48358         return ret_ref;
48359 }
48360
48361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
48362         LDKStr a_conv = java_to_owned_str(env, a);
48363         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48364         *ret_copy = PaymentError_invoice(a_conv);
48365         int64_t ret_ref = (uintptr_t)ret_copy;
48366         return ret_ref;
48367 }
48368
48369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
48370         LDKLightningError a_conv;
48371         a_conv.inner = (void*)(a & (~1));
48372         a_conv.is_owned = (a & 1) || (a == 0);
48373         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48374         a_conv = LightningError_clone(&a_conv);
48375         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48376         *ret_copy = PaymentError_routing(a_conv);
48377         int64_t ret_ref = (uintptr_t)ret_copy;
48378         return ret_ref;
48379 }
48380
48381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
48382         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
48383         CHECK_ACCESS(a_ptr);
48384         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
48385         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
48386         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48387         *ret_copy = PaymentError_sending(a_conv);
48388         int64_t ret_ref = (uintptr_t)ret_copy;
48389         return ret_ref;
48390 }
48391
48392 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) {
48393         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
48394         CHECK_ACCESS(payer_ptr);
48395         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
48396         if (payer_conv.free == LDKPayer_JCalls_free) {
48397                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48398                 LDKPayer_JCalls_cloned(&payer_conv);
48399         }
48400         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
48401         CHECK_ACCESS(router_ptr);
48402         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
48403         if (router_conv.free == LDKRouter_JCalls_free) {
48404                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48405                 LDKRouter_JCalls_cloned(&router_conv);
48406         }
48407         LDKMultiThreadedLockableScore scorer_conv;
48408         scorer_conv.inner = (void*)(scorer & (~1));
48409         scorer_conv.is_owned = false;
48410         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
48411         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
48412         CHECK_ACCESS(logger_ptr);
48413         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48414         if (logger_conv.free == LDKLogger_JCalls_free) {
48415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48416                 LDKLogger_JCalls_cloned(&logger_conv);
48417         }
48418         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
48419         CHECK_ACCESS(event_handler_ptr);
48420         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
48421         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
48422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48423                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
48424         }
48425         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
48426         CHECK_ACCESS(retry_ptr);
48427         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
48428         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
48429         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
48430         int64_t ret_ref = 0;
48431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48434         ret_ref = (uintptr_t)ret_var.inner;
48435         if (ret_var.is_owned) {
48436                 ret_ref |= 1;
48437         }
48438         return ret_ref;
48439 }
48440
48441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
48442         LDKInvoicePayer this_arg_conv;
48443         this_arg_conv.inner = (void*)(this_arg & (~1));
48444         this_arg_conv.is_owned = false;
48445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48446         LDKInvoice invoice_conv;
48447         invoice_conv.inner = (void*)(invoice & (~1));
48448         invoice_conv.is_owned = false;
48449         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
48450         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
48451         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
48452         return (int64_t)ret_conv;
48453 }
48454
48455 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) {
48456         LDKInvoicePayer this_arg_conv;
48457         this_arg_conv.inner = (void*)(this_arg & (~1));
48458         this_arg_conv.is_owned = false;
48459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48460         LDKInvoice invoice_conv;
48461         invoice_conv.inner = (void*)(invoice & (~1));
48462         invoice_conv.is_owned = false;
48463         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
48464         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
48465         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
48466         return (int64_t)ret_conv;
48467 }
48468
48469 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) {
48470         LDKInvoicePayer this_arg_conv;
48471         this_arg_conv.inner = (void*)(this_arg & (~1));
48472         this_arg_conv.is_owned = false;
48473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48474         LDKPublicKey pubkey_ref;
48475         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
48476         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
48477         LDKThirtyTwoBytes payment_preimage_ref;
48478         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
48479         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
48480         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
48481         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
48482         return (int64_t)ret_conv;
48483 }
48484
48485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
48486         LDKInvoicePayer this_arg_conv;
48487         this_arg_conv.inner = (void*)(this_arg & (~1));
48488         this_arg_conv.is_owned = false;
48489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48490         unsigned char payment_hash_arr[32];
48491         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
48492         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
48493         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
48494         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
48495 }
48496
48497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
48498         LDKInvoicePayer this_arg_conv;
48499         this_arg_conv.inner = (void*)(this_arg & (~1));
48500         this_arg_conv.is_owned = false;
48501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48502         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
48503         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
48504         return (int64_t)ret_ret;
48505 }
48506
48507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
48508         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48509         CHECK_ACCESS(amt_msat_ptr);
48510         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48511         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48512         LDKThirtyTwoBytes payment_hash_ref;
48513         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
48514         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
48515         LDKStr description_conv = java_to_owned_str(env, description);
48516         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
48517         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
48518         if (phantom_route_hints_constr.datalen > 0)
48519                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
48520         else
48521                 phantom_route_hints_constr.data = NULL;
48522         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
48523         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
48524                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
48525                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
48526                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
48527                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
48528                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
48529                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
48530                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
48531         }
48532         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
48533         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48534         CHECK_ACCESS(keys_manager_ptr);
48535         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48536         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48537                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48538                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48539         }
48540         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48541         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48542         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, network_conv);
48543         return (int64_t)ret_conv;
48544 }
48545
48546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
48547         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48548         CHECK_ACCESS(amt_msat_ptr);
48549         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48550         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48551         LDKThirtyTwoBytes payment_hash_ref;
48552         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
48553         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
48554         LDKSha256 description_hash_conv;
48555         description_hash_conv.inner = (void*)(description_hash & (~1));
48556         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48557         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48558         description_hash_conv = Sha256_clone(&description_hash_conv);
48559         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
48560         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
48561         if (phantom_route_hints_constr.datalen > 0)
48562                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
48563         else
48564                 phantom_route_hints_constr.data = NULL;
48565         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
48566         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
48567                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
48568                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
48569                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
48570                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
48571                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
48572                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
48573                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
48574         }
48575         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
48576         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48577         CHECK_ACCESS(keys_manager_ptr);
48578         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48579         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48580                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48581                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48582         }
48583         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48584         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48585         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, keys_manager_conv, network_conv);
48586         return (int64_t)ret_conv;
48587 }
48588
48589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs) {
48590         LDKChannelManager channelmanager_conv;
48591         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48592         channelmanager_conv.is_owned = false;
48593         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48594         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48595         CHECK_ACCESS(keys_manager_ptr);
48596         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48597         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48598                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48599                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48600         }
48601         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48602         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48603         CHECK_ACCESS(amt_msat_ptr);
48604         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48605         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48606         LDKStr description_conv = java_to_owned_str(env, description);
48607         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48608         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
48609         return (int64_t)ret_conv;
48610 }
48611
48612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
48613         LDKChannelManager channelmanager_conv;
48614         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48615         channelmanager_conv.is_owned = false;
48616         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48617         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48618         CHECK_ACCESS(keys_manager_ptr);
48619         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48620         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48621                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48622                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48623         }
48624         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48625         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48626         CHECK_ACCESS(amt_msat_ptr);
48627         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48628         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48629         LDKSha256 description_hash_conv;
48630         description_hash_conv.inner = (void*)(description_hash & (~1));
48631         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48632         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48633         description_hash_conv = Sha256_clone(&description_hash_conv);
48634         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48635         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
48636         return (int64_t)ret_conv;
48637 }
48638
48639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
48640         LDKChannelManager channelmanager_conv;
48641         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48642         channelmanager_conv.is_owned = false;
48643         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48644         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48645         CHECK_ACCESS(keys_manager_ptr);
48646         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48647         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48649                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48650         }
48651         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48652         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48653         CHECK_ACCESS(amt_msat_ptr);
48654         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48655         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48656         LDKSha256 description_hash_conv;
48657         description_hash_conv.inner = (void*)(description_hash & (~1));
48658         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48659         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48660         description_hash_conv = Sha256_clone(&description_hash_conv);
48661         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48662         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
48663         return (int64_t)ret_conv;
48664 }
48665
48666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
48667         LDKChannelManager channelmanager_conv;
48668         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48669         channelmanager_conv.is_owned = false;
48670         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48671         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48672         CHECK_ACCESS(keys_manager_ptr);
48673         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48674         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48676                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48677         }
48678         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48679         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48680         CHECK_ACCESS(amt_msat_ptr);
48681         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48682         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48683         LDKStr description_conv = java_to_owned_str(env, description);
48684         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48685         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
48686         return (int64_t)ret_conv;
48687 }
48688
48689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48690         LDKDefaultRouter this_obj_conv;
48691         this_obj_conv.inner = (void*)(this_obj & (~1));
48692         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48694         DefaultRouter_free(this_obj_conv);
48695 }
48696
48697 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) {
48698         LDKNetworkGraph network_graph_conv;
48699         network_graph_conv.inner = (void*)(network_graph & (~1));
48700         network_graph_conv.is_owned = false;
48701         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48702         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
48703         CHECK_ACCESS(logger_ptr);
48704         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48705         if (logger_conv.free == LDKLogger_JCalls_free) {
48706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48707                 LDKLogger_JCalls_cloned(&logger_conv);
48708         }
48709         LDKThirtyTwoBytes random_seed_bytes_ref;
48710         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
48711         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
48712         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
48713         int64_t ret_ref = 0;
48714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48717         ret_ref = (uintptr_t)ret_var.inner;
48718         if (ret_var.is_owned) {
48719                 ret_ref |= 1;
48720         }
48721         return ret_ref;
48722 }
48723
48724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
48725         LDKDefaultRouter this_arg_conv;
48726         this_arg_conv.inner = (void*)(this_arg & (~1));
48727         this_arg_conv.is_owned = false;
48728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48729         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
48730         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
48731         return (int64_t)ret_ret;
48732 }
48733
48734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
48735         LDKChannelManager this_arg_conv;
48736         this_arg_conv.inner = (void*)(this_arg & (~1));
48737         this_arg_conv.is_owned = false;
48738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48739         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
48740         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
48741         return (int64_t)ret_ret;
48742 }
48743
48744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48745         LDKStr s_conv = java_to_owned_str(env, s);
48746         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
48747         *ret_conv = SiPrefix_from_str(s_conv);
48748         return (int64_t)ret_conv;
48749 }
48750
48751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48752         LDKStr s_conv = java_to_owned_str(env, s);
48753         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
48754         *ret_conv = Invoice_from_str(s_conv);
48755         return (int64_t)ret_conv;
48756 }
48757
48758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48759         LDKStr s_conv = java_to_owned_str(env, s);
48760         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
48761         *ret_conv = SignedRawInvoice_from_str(s_conv);
48762         return (int64_t)ret_conv;
48763 }
48764
48765 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48766         LDKParseError* o_conv = (LDKParseError*)o;
48767         LDKStr ret_str = ParseError_to_str(o_conv);
48768         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48769         Str_free(ret_str);
48770         return ret_conv;
48771 }
48772
48773 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48774         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
48775         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
48776         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48777         Str_free(ret_str);
48778         return ret_conv;
48779 }
48780
48781 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48782         LDKInvoice o_conv;
48783         o_conv.inner = (void*)(o & (~1));
48784         o_conv.is_owned = false;
48785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48786         LDKStr ret_str = Invoice_to_str(&o_conv);
48787         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48788         Str_free(ret_str);
48789         return ret_conv;
48790 }
48791
48792 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48793         LDKSignedRawInvoice o_conv;
48794         o_conv.inner = (void*)(o & (~1));
48795         o_conv.is_owned = false;
48796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48797         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
48798         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48799         Str_free(ret_str);
48800         return ret_conv;
48801 }
48802
48803 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48804         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
48805         LDKStr ret_str = Currency_to_str(o_conv);
48806         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48807         Str_free(ret_str);
48808         return ret_conv;
48809 }
48810
48811 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48812         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
48813         LDKStr ret_str = SiPrefix_to_str(o_conv);
48814         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48815         Str_free(ret_str);
48816         return ret_conv;
48817 }
48818
48819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48820         LDKRapidGossipSync this_obj_conv;
48821         this_obj_conv.inner = (void*)(this_obj & (~1));
48822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48824         RapidGossipSync_free(this_obj_conv);
48825 }
48826
48827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
48828         LDKNetworkGraph network_graph_conv;
48829         network_graph_conv.inner = (void*)(network_graph & (~1));
48830         network_graph_conv.is_owned = false;
48831         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48832         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
48833         int64_t ret_ref = 0;
48834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48837         ret_ref = (uintptr_t)ret_var.inner;
48838         if (ret_var.is_owned) {
48839                 ret_ref |= 1;
48840         }
48841         return ret_ref;
48842 }
48843
48844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1sync_1network_1graph_1with_1file_1path(JNIEnv *env, jclass clz, int64_t this_arg, jstring sync_path) {
48845         LDKRapidGossipSync this_arg_conv;
48846         this_arg_conv.inner = (void*)(this_arg & (~1));
48847         this_arg_conv.is_owned = false;
48848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48849         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
48850         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48851         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
48852         return (int64_t)ret_conv;
48853 }
48854
48855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
48856         LDKRapidGossipSync this_arg_conv;
48857         this_arg_conv.inner = (void*)(this_arg & (~1));
48858         this_arg_conv.is_owned = false;
48859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48860         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
48861         return ret_conv;
48862 }
48863
48864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48865         if ((this_ptr & 1) != 0) return;
48866         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48867         CHECK_ACCESS(this_ptr_ptr);
48868         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
48869         FREE((void*)this_ptr);
48870         GraphSyncError_free(this_ptr_conv);
48871 }
48872
48873 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
48874         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48875         *ret_copy = GraphSyncError_clone(arg);
48876 int64_t ret_ref = (uintptr_t)ret_copy;
48877         return ret_ref;
48878 }
48879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48880         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
48881         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
48882         return ret_conv;
48883 }
48884
48885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48886         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
48887         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48888         *ret_copy = GraphSyncError_clone(orig_conv);
48889         int64_t ret_ref = (uintptr_t)ret_copy;
48890         return ret_ref;
48891 }
48892
48893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
48894         LDKDecodeError a_conv;
48895         a_conv.inner = (void*)(a & (~1));
48896         a_conv.is_owned = (a & 1) || (a == 0);
48897         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48898         a_conv = DecodeError_clone(&a_conv);
48899         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48900         *ret_copy = GraphSyncError_decode_error(a_conv);
48901         int64_t ret_ref = (uintptr_t)ret_copy;
48902         return ret_ref;
48903 }
48904
48905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
48906         LDKLightningError a_conv;
48907         a_conv.inner = (void*)(a & (~1));
48908         a_conv.is_owned = (a & 1) || (a == 0);
48909         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48910         a_conv = LightningError_clone(&a_conv);
48911         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48912         *ret_copy = GraphSyncError_lightning_error(a_conv);
48913         int64_t ret_ref = (uintptr_t)ret_copy;
48914         return ret_ref;
48915 }
48916
48917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
48918         LDKRapidGossipSync this_arg_conv;
48919         this_arg_conv.inner = (void*)(this_arg & (~1));
48920         this_arg_conv.is_owned = false;
48921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48922         LDKu8slice update_data_ref;
48923         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
48924         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
48925         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48926         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
48927         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
48928         return (int64_t)ret_conv;
48929 }
48930